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.
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. namespace PreDefineFactorialNumber {
  7. class Program {
  8. static void Main(string[] args) {
  9. int num, a = 1, Fact = 1;
  10. Console.WriteLine("Enter The Other Number = ");
  11. num = Convert.ToInt32(Console.ReadLine());
  12. while (a <= num) {
  13. Fact = Fact * a;
  14. a++;
  15. Console.WriteLine("The Factorial Number is " + Fact);
  16. }
  17. Console.ReadLine();
  18. }
  19. }
  20. }
Now run the predefined factorial number code
Click on start button and debug the program
Predefine Factorial Number Using C# Code
Output tof he predefined factorial number code
Predefine Factorial Number Using C# Code
I hope you understood how to predefine a factorial number using C# Code.