#include <iostream>
using namespace std;
int faktorial (int bil)
{
if(bil==0||bil==1)
return 1;
else
return bil*faktorial(bil-1);
}
int main ()
{
int n;
cout<<"\tFungsi Rekursif Bilangan Faktorial"<<endl;
cout<<"\nMasukkan nilai n = ";
cin>>n;
cout<<"\nFaktorial "<<n<<"!= "<<faktorial(n)<<endl;
return 0;
}
Comments
Post a Comment