In this blog, we will write a C# program to predefine a factorial number.
Predefine Factorial Number in C# Code
First predefine the factorial number. This code sample shows you how to do it in C# Code.
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace PreDefineFactorialNumber {
- class Program {
- static void Main(string[] args) {
- int num, a = 1, Fact = 1;
- Console.WriteLine("Enter The Other Number = ");
- num = Convert.ToInt32(Console.ReadLine());
- while (a <= num) {
- Fact = Fact * a;
- a++;
- Console.WriteLine("The Factorial Number is " + Fact);
- }
- Console.ReadLine();
- }
- }
- }
Now run the predefined factorial number code
Click on start button and debug the program
Output tof he predefined factorial number code
I hope you understood how to predefine a factorial number using C# Code.