How to get factorial in c#

May 02, 2013

How to get factorial in c#


Write a program which calculates factorial of a number entered by the user until the user decides to exit.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Calculator
    class Program
        static void Main(string[] args)

char ch;

            int Value;
            int Fact = 1;
                Console.WriteLine(" Enter The Number Which Number You Want To Calculate The Factorial\n");
                Console.Write("Number Is : ");
                Value = int.Parse(Console.ReadLine());
                for (int i = 1; i <= Value; i++)
                    Fact = Fact * i;
                    Console.WriteLine("Factorial is  : " + Fact);
                    Console.WriteLine("Do You Want TO Continue....(y/N)\n");

                    ch = char.Parse(Console.ReadLine());
            while (ch == 'y');


You Might Also Like


Popular Posts

Like us on Facebook

Flickr Images