factorial
Numbers factorial is the multiplication of positive integers less than or equal to n. Factorial is usually written with n! and usually called n factorial. Factorial Numbers eg 4!, that means 4 x 3 x 2 x 1.
sample number factorial program C + +:
#include
long int faktorial(int a)
{
if (a==0 || a==1)
#include
long int faktorial(int a)
{
if (a==0 || a==1)
return 1;
else
else
return a*faktorial(a-1);
}
int main()
{
}
int main()
{
int bil, a,x;
long int jumlah;
cout<<"Masukkan bilangan a = ";
cin>>a;
jumlah = faktorial(a);
cout<<<"!="jumlah;
cin>>x;
return 0;
}
cin>>a;
jumlah = faktorial(a);
cout<<<"!="jumlah;
cin>>x;
return 0;
}
0 komentar:
Posting Komentar