Advertisement
fahimkamal63

Factorial in c#

Oct 18th, 2021
640
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.36 KB | None | 0 0
  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. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement