Want to become a Vibe Coder? Join Vibe Coding Training here
x
C# Corner
Tech
News
Videos
Forums
Jobs
Books
Events
More
Interviews
Live
Learn
Training
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
771
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