using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication16
{
class Program
{
private static long Factorial(int n)
{
if (n == 0)
{
return 1;
}
return n * Factorial(n - 1);
}
static void Main(string[] args)
{
int a;
Console.WriteLine("Enter a number");
a = int.Parse(Console.ReadLine());
long fact = Factorial(a);
Console.WriteLine("{0} factorial is {1}", a, fact);
Console.ReadKey();
}
}
}
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication16
{
class Program
{
private static long Factorial(int n)
{
if (n == 0)
{
return 1;
}
return n * Factorial(n - 1);
}
static void Main(string[] args)
{
int a;
Console.WriteLine("Enter a number");
a = int.Parse(Console.ReadLine());
long fact = Factorial(a);
Console.WriteLine("{0} factorial is {1}", a, fact);
Console.ReadKey();
}
}
}
No comments:
Post a Comment