factorial recursive function
#include<stdio.h>
long long int fac(long long a)
{
if(a==0)
{
return 1;
}
return a*fac(a-1);
}
int main()
{
long long int a;
while(scanf("%lld",&a)!=EOF)
{
long long int n=fac(a);
printf("factorial = %lld\n",n);
}
return 0;
}
No comments:
Post a Comment