C# Corner
Tech
News
Videos
Forums
Trainings
Books
Live
More
Interviews
Events
Jobs
Learn
Career
Members
Blogs
Challenges
Certifications
Bounties
Contribute
Article
Blog
Video
Ebook
Interview Question
Collapse
Feed
Dashboard
Wallet
Learn
Achievements
Network
Refer
Rewards
SharpGPT
Premium
Contribute
Article
Blog
Video
Ebook
Interview Question
Register
Login
Factorial using Recursion
WhatsApp
Kaushik S
Apr 03
2016
837
0
0
//Factorial using recursion
#include <stdio.h>
int
FactorialRecursion(
int
n,
int
fact);
int
main()
{
int
result=0,n=0,fact=1;
printf(
"Factorial of a number\n"
);
printf(
"-------------\n"
);
printf(
"Enter the number\n"
);
scanf(
"%d"
,&n);
result=FactorialRecursion(n,fact);
printf(
"The factorial of the number %d is %d\n"
,n,result);
return
0;
}
int
FactorialRecursion(
int
n,
int
fact)
{
if
(n<1)
{
return
fact;
}
fact=fact*n;
return
FactorialRecursion(n-1,fact);
}
C
Up Next
Factorial using Recursion