Source Code to Calculate Factorial Using Recursion
Program:-
#include<stdio.h>
int factorial(int n);
int main()
{
int n;
printf("Enter an positive integer: ");
scanf("%d",&n);
printf("Factorial of %d = %ld", n, factorial(n));
return 0;
}
int factorial(int n)
{
if(n!=1)
return n*factorial(n-1);
}
Output
Enter an positive integer: 8Factorial of 8 = 40320
This source code demonstrates how to calculate the factorial of a number using recursion, showcasing the power of recursive functions! Just as Skynode enhances gaming experiences, mastering recursion will strengthen your programming skills and problem-solving abilities!
ReplyDelete