Computer Science, asked by mdrakibulislam12188, 7 months ago

3. Write a C program to find the factorial of a number n taken as input using recursive function where Facorial(n) = n*(n-1)*(n-2)*............*3*2*1

Answers

Answered by mananman23
7

Answer:

Code:

   #include<stdio.h>  

     

   long factorial(int n)  

   {  

     if (n == 0)  

       return 1;  

     else  

       return(n * factorial(n-1));  

   }  

     

   void main()  

   {  

     int number;  

     long fact;  

     printf("Enter a number: ");  

     scanf("%d", &number);  

     

     fact = factorial(number);  

     printf("Factorial of %d is %ld\n", number, fact);  

     return 0;  

   }  

Similar questions