ry
{
// Convert the input arguments to numbers:
int num = int.Parse(args[0]);
System.
Console.WriteLine("The Factorial of {0} is {1}.", num, Functions.Factorial(num));
return 0;
}
received eror the name fuction does not exist in the current text
ry
{
// Convert the input arguments to numbers:
int num = int.Parse(args[0]);
System.
Console.WriteLine("The Factorial of {0} is {1}.", num, Functions.Factorial(num));
return 0;
}
received eror the name fuction does not exist in the current text
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Sanjeeb LenkaPosted Jul 24, 2013, 1:15 AM
using System;
using System.Collections.Generic;
using System.Text;
class Class2
{
static int Fact(int n)
{
if (n <= 1)
return 1;
return n * Fact(n - 1);
}
static void Main(string[] args)
{
Console.Write("Enter a Number to find factorial: ");
int n = Convert.ToInt32(Console.ReadLine());
int r = Fact(n);
Console.WriteLine(n.ToString() + "! = " + r.ToString());
Console.ReadLine();
}
or you can try this
using System;
using System.Collections.Generic;
using System.Text;
class Class2
{
static int Factorial(int n)
{
if (n <= 1)
return 1;
int result = 1;
for (int i = 2; i <= n; i++)
{
result = result * i;
}
return result;
}
static void Main(string[] args)
{
Console.Write("Enter a Number to find factorial: ");
int n = Convert.ToInt32(Console.ReadLine());
int r = Factorial(n);
Console.WriteLine(n.ToString() + "! = " + r.ToString());
Console.ReadLine();
}
}
}
Iftikar HussainPosted Jul 24, 2013, 1:01 AM
Try like this
Regards,
Iftikar