Find Factorial using Recursion | C Program:

Write a C Program to Find Factorial User given using Recursion :

 

About factorial:

5! = 5!x4!x3!x2!x1!  = 120

Code:

#include<stdio.h>

void main()
{
    int facto(int);
    int n,b;
    printf("Enter a range of factorial:\n");
    scanf("%d",&n);
    b=facto(n);
    printf("\nThe factorial of %d is %d",n,b);
}
int facto(int n)
{
    if(n==1)
        return n;
    else
        n=n*facto(n-1);
        return n;
}

Output:

Comments

Popular posts from this blog

Print name in a pattern | name as abbreviation | C-Program

Print Fibonacci Series using Recursion | C program :