Question { 27506 }
"c sharp" code for factorial using static variables
Answer
The answer posted above by Arup Ratan Banerjee is entirely
wrong.he is just taking an input value and sending it as an
argument to factorial method and multiplying it with value
of y, which is 1 and then he is returing that result,which
is the input value only.
try this code in C#:
public class test1
{
public static void Main(string[] args){
int fact=0;
Console.WriteLine("Enter A Number:");
fact = Convert.ToInt32(Console.ReadLine());
for (int i=1; i<=fact; i++){
if (fact%i == 0){ //It works
System.Console.WriteLine(i);
}
}
Console.Read();
}
}