Thursday, 31 May 2012

Factorial of a number in C#



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

namespace ConsoleApplication
{
    class Program
    {
        static void Main(string[] args)
        {
            int i, n, f;
            Console.WriteLine("enter the value of n");
            n = Convert.ToInt32(Console.ReadLine());
            f = n;
            for (i = n - 1; i >= 1; i--)
            {
                f = f * i;
            }
            Console.WriteLine("Factorial of given number is :" + f);
            Console.Read();
        }
    }
}

3 comments:

CRUD operations using AngularJS in Asp.Net MVC

In this article I will show you how to perform CRUD operations in Asp.Net MVC5 using AngularJS. Add AngularJS using the Manage Nuget Pack...