Welcome to W3Courses
 Like Us on Facebook

Recursive

Source Code for Calculating Factorial of a Number using a Recursive Function in C Programming

Following is the source code for calculating the factorial of a number using a Recursive Function in C Programming.

int f(int n)
{
  if (n==0)
    return 1;
  if (n>0)
    return n*f(n-1);
}
main()
{
  int n;
  printf("Enter a number between 0 and 33: ");
  scanf("%d",&n);
  printf("%d\n",f(n));
}

Share