我有一个简单的程序,应该计算输入数字的阶乘。它说我没有错误,但是当我运行程序时它停止并且不起作用。有人可以告诉我为什么吗?
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
{
for (int i = 1; 1 <= userNumber; i++)
{
numberFactorial = numberFactorial * i;
numberOutput.Text = numberFactorial.ToString();
}
}
}
}
}