Factorial program in C#

C# Programming Language / Loop control in C# Language

265

Program:

using System;  
  public class FactorialExample  
   {  
     public static void Main(string[] args)  
      {  
       int i,fact=1,number;      
       Console.Write("Enter any Number: ");      
       number= int.Parse(Console.ReadLine());     
       for(i=1;i<=number;i++){      
        fact=fact*i;      
       }      
       Console.Write("Factorial of " +number+" is: "+fact);    
     }  
  }  

Output:

Enter any Number: 6
Factorial of 6 is: 720

Explanation:

None

This Particular section is dedicated to Programs only. If you want learn more about C# Programming Language. Then you can visit below links to get more depth on this subject.