1
Answer

method problems

Bing In

Bing In

8y
326
1
I want to calculate a factorial(n!) input as an interger "n"
I found there is an error at Fact(n); 
error says 
The name 'n' does not exist int the current context 
what`s wrong with the n in Fact() method?
 
 
 

 
 
 
public static void Main()
{
Console.WriteLine("Type an integer");
string factorial = Console.ReadLine();
Fact(n);
}
public static void Fact(int n)
 {
   if (n == 0)
      {
         n = 1;
      }
      else if (n >= 1)
      {
      for (int i = 1; i < n; i++)
      {
         n = n * i;
      }
 }
Answers (1)