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.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend4days leftRegister
Iftikar HussainRank #423 · 5.9K reputationPosted Jul 23, 2013, 9:01 PM EDT
Try like this
Regards,
Iftikar
Sanjeeb LenkaRank #301 · 8.3K reputationPosted Jul 23, 2013, 9:15 PM EDT
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();
}
}
}