Enter the Number 6 Factorial of Given Number is: 720
Users Online
· Guests Online: 93
· Members Online: 0
· Total Members: 188
· Newest Member: meenachowdary055
· Members Online: 0
· Total Members: 188
· Newest Member: meenachowdary055
Forum Threads
Newest Threads
No Threads created
Hottest Threads
No Threads created
Latest Articles
Articles Hierarchy
Factorial Program in C#
Factorial Program in C#
This is a C# Program to generate the factorial of given number.
Problem Description
This C# Program generates Factorial of the Number obtained from the user.
Problem Solution
Factorial of a number is obtained from the result of multiplying a series of descending natural numbers.
Program/Source Code
Here is source code of the C# Program to Generate the Factorial of Given Number. The C# program is successfully compiled and executed with Microsoft Visual Studio. The program output is also shown below.
/* * C# Program to Generate the Factorial of Given Number */ using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace factorial { class Program { static void Main(string[] args) { int i, number, fact; Console.WriteLine("Enter the Number"); number = int.Parse(Console.ReadLine()); fact = number; for (i = number - 1; i >= 1; i--) { fact = fact * i; } Console.WriteLine("\nFactorial of Given Number is: "+fact); Console.ReadLine(); } } }
Program Explanation
In this C# program, we are reading the number using ‘number’ variable. Using for loop, factorial of a number is obtained from the result of multiplying a series of descending natural numbers. Print the factorial of given number.
Runtime Test Cases
Comments
No Comments have been Posted.
Post Comment
Please Login to Post a Comment.