/ Published in: C#
Just compile in your command line and run
how to compile : csc Factorial.cs
how to compile : csc Factorial.cs
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
public class Factorial { public static void Main(string[] args) { string op; System.Console.Write("Input number : "); op = System.Console.ReadLine(); System.Console.WriteLine(CalculateFactorial(int.Parse(op))); } public static int CalculateFactorial(int pNumber) { int result = 1; for (int i = 1; i <= pNumber; i++) { result = result * i; } return result; } }