TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
C# Corner
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
How to Get Factorial Value in C#
Mukesh Kumar
Nov 23
2015
Code
1.3
k
0
0
facebook
twitter
linkedIn
Reddit
WhatsApp
Email
Bookmark
expand
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