everything happens for a reason,, sometimes things fall apart so other things can fall together but what's meant to be will always find a way *_^

Kamis, 31 Maret 2011

program mencari hasil n faktorial

aiii guys,, here one example of a program to search results of n factorial i hope that it can help to finish up your problem.... _^ ........

#include <iostream>
#include <math.h>
using namespace std ;
int faktorial(int a);
int main ()

{
int n;
cout << "Masukkan bilangan : " ;
cin >> n ;
cout << "Faktorial " << n <<" = " << faktorial (n) ;cout << "\n";
}
int faktorial (int a)
{
int hasil ;
if (a <= 1)
{ hasil = 1; }
else
{ hasil = a*faktorial(a-1); }
return (hasil) ;
}

1 komentar: