1//using recursion to find factorial of a number
2
3#include<stdio.h>
4
5int fact(int n);
6
7int main()
8{
9 int n;
10 printf("Enter the number: ");
11 scanf("%d",&n);
12
13 printf("Factorial of %d = %d", n, fact(n));
14
15}
16
17int fact(int n)
18
19{
20 if (n>=1)
21 return n*fact(n-1);
22 else
23 return 1;
24}
1#include <stdio.h>
2int factorial(int number){
3 if(number==1){
4 return number;
5 }
6 return number*factorial(number - 1);
7}
8int main(){
9 int a=factorial(5);
10 printf("%d",a);
11}
12