Solved programming problem

Finding Factorial with Recursion in C.

Source code

#include <stdio.h>

int  factorial(int n)

{

    if(n==1)

    {

        return 1; ///base case

    }

    else

    {

        return n*factorial(n-1); ///calling the same function

    }

}

int main()

{

   int n;

   printf("Please Enter A value: ");

   scanf("%d",&n);

   factorial(n);

   printf("
Factorial: %d
",factorial(n));

    return 0;

}

Output

Please Enter A value: 15

Factorial: 2004310016

Join the discussion

Add your comment