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
Certification
Bounty
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
How to Get Factorial Value in C#
WhatsApp
Mukesh Kumar
Nov 23
2015
1.4
k
0
0
public
static
int
Factorial(
this
int
i)
{
int
factorial = 1;
for
(
int
j = i; j > 0; j--)
{
factorial *= j;
}
return
factorial;
}
And call this method as following:
int
i = 5;
Console.WriteLine(
"Factorial of {0} is {1}"
, i, i.Factorial());
C#
Factorial Value
Up Next
How to Get Factorial Value in C#