C Program find the Factorial of the given number using Recursion

Recursion:
      It is a technique that makes a method calls itself repeatedly until some base condition is satisfied.

for more on recursion, Visit:
http://en.wikipedia.org/wiki/Recursion



Source Code:
/*   
  Program to find a factorial of number using recursion   
  Author: sourcecodesonline.blogspot.com
*/  
#include<stdio.h>  
int factorial(int);  
int main(void)
{  
  int no,i,fact;  
  printf("\nEnter the number: ");  
  scanf("%d",&no);  
  fact=factorial(no); //function to return the factorial the parameter passed  
  printf("\nThe factorial of number %d is %d\n",no,fact);  
 return 1;  
}  
  
//recursive function to find factorial of a number  
  
int factorial(int n)  
{  
  if(n==0)//base condition  
    return 1;  
  else  
   {  
     return n * factorial(n-1);   
   }  
    Previous
    Next Post »

    If you still didn't find what you're looking for, you can search this website below: