Bing In

Bing In

  • NA
  • 30
  • 9.1k

method problems

Apr 18 2016 5:49 AM
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)