Files
  • main.cs
  • main.exe
main.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
using System;

class FactorialWhileLoopExample {
    public static void Main() {
        int n = 5;
        int factorial = 1;
        while (n > 1)
        {
            factorial = factorial * n;
            n--;
        }
        Console.WriteLine(factorial);
    }
}