fahimkamal63

Factorial in c#

Oct 18th, 2021
523
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using System;
  2.  
  3. class Factorial
  4. {
  5.     static void Main()
  6.     {
  7.         Console.Write("Enter a int value: ");
  8.  
  9.         int num = Convert.ToInt32(Console.ReadLine());
  10.         int factorial = 1;
  11.         for (int i = num; i > 0; i--) {
  12.             factorial *= i;
  13.         }
  14.  
  15.         Console.WriteLine("The factorial of {0} is: {1}", num, factorial);
  16.     }
  17. }
RAW Paste Data