C# Program To User-Define Factorial Number

Introduction 

 
In this blog, we will write a C# program to user-define a factorial number.
 

User-Define Factorial number in C#

 
This code sample shows you how to user-define a factorial number in C#:
  1. using System;  
  2. using System.Collections.Generic;  
  3. using System.Linq;  
  4. using System.Text;  
  5. using System.Threading.Tasks;  
  6. namespace UserDefineFactorialNumber {  
  7.     class Program {  
  8.         static void Main(string[] args) {  
  9.             int a = 1, Fact = 1;  
  10.             int Num = 5;  
  11.             while (a <= Num) {  
  12.                 Fact = Fact * a;  
  13.                 a++;  
  14.                 Console.WriteLine("The Factorial Number is " + Fact);  
  15.             }  
  16.             Console.ReadLine();  
  17.         }  
  18.     }  
  19. }   
Now run the user-defined factorial number code
 
Click on the Start button:
 
C# Program to User Define Factorial Number
 
Output of the code:
 
C# Program to User Define Factorial Number
 
I hope you understood how to user-define a factorial number using C# code.