Hi Friend's ,Here I have Written code for Factorial using recursion in c#.
code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace FactorialUsingRecursion
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Enter number.........");
int n = Convert.ToInt32(Console.ReadLine());
Console.WriteLine(Factorial(n));
Console.Read();
}
static long
Factorial(int number)
{
if
(number < 1)
return 1;
else
return number * Factorial(number - 1);
}
}
}
No comments:
Post a Comment
Note: only a member of this blog may post a comment.