visual studio 2010 - Calculating Factorials in C# - No Errors, But Doesn't Work? -
i have simple program supposed calculate factorial of entered number. says have no errors, when run program stalls , not work. can please tell me why?
private void getfactorial_click(object sender, eventargs e) { int usernumber, numberfactorial = 1; usernumber = int.parse(numberinput.text); if (usernumber <= 0) { numberoutput.text = numberfactorial.tostring(); } else { (int = 1; 1 <= usernumber; i++) { numberfactorial = numberfactorial * i; numberoutput.text = numberfactorial.tostring(); } } } }
}
it's simple things us.
in loop have this:
for (int = 1; 1 <= usernumber; i++)
i believe mean this:
for (int = 1; <= usernumber; i++)
in conditional part of loop used '1' rather 'i'.
Comments
Post a Comment