Recursion_factorial
#include<stdio.h>
int factorial(int n);
int main()
{
int n;
printf("Enter an positive integer: ");
scanf("%d",&n);
printf("%d! = %d", n, factorial(n));
return 0;
}
int factorial(int n)
{
if(n==1 || n==0){
return 1;
}
else if (n!=1)
return n*factorial(n-1);
}
No comments:
Post a Comment