C#阶乘问题计算阶乘.比如用户在TextBox里输入7,就会显示 :The factorial of 1 is 1The factorial of 2 is 2The factorial of 3 is 6The factorial of 4 is 24The factorial of 5 is 120The factorial of 6 is 720The factorial of 7 is 5040.这

来源:学生作业帮助网 编辑:作业帮 时间:2024/05/07 07:07:24
C#阶乘问题计算阶乘.比如用户在TextBox里输入7,就会显示 :The factorial of 1 is 1The factorial of 2 is 2The factorial of 3 is 6The factorial of 4 is 24The factorial of 5 is 120The factorial of 6 is 720The factorial of 7 is 5040.这

C#阶乘问题计算阶乘.比如用户在TextBox里输入7,就会显示 :The factorial of 1 is 1The factorial of 2 is 2The factorial of 3 is 6The factorial of 4 is 24The factorial of 5 is 120The factorial of 6 is 720The factorial of 7 is 5040.这
C#阶乘问题
计算阶乘.比如用户在TextBox里输入7,就会显示 :
The factorial of 1 is 1
The factorial of 2 is 2
The factorial of 3 is 6
The factorial of 4 is 24
The factorial of 5 is 120
The factorial of 6 is 720
The factorial of 7 is 5040
.
这是我的代码,这是乘方,怎么写阶乘?
//Declare variables
int numRow =0;
int i = 0;
public calculateButton()
{
InitializeComponent();
}
private void buttonCalculate_Click(object sender,EventArgs e)
{
if (int.TryParse(textBoxnumber.Text,out numRow) == true)
{
for (int i = 1; i

C#阶乘问题计算阶乘.比如用户在TextBox里输入7,就会显示 :The factorial of 1 is 1The factorial of 2 is 2The factorial of 3 is 6The factorial of 4 is 24The factorial of 5 is 120The factorial of 6 is 720The factorial of 7 is 5040.这
在最前面加:
double sum = 1;

int i = 0;一起


for语句内修改:
for (int i = 1; i