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 »

    Still not found what you are looking for? Try again here.