编写一个C#窗体程序,对于输入的正整数n,计算1!+2!+3+…+n!的值并输出。(需要考虑下,当 100
2015-05-14
private int f(int i)
{
if (i == 1)
{
轿启扒 return 1;
}
else
{
return f(i - 1) + g(i);
旁码 }
}
private int g(int i)
{
if (i == 1)
{
return 1;
}
else
{
闭昌 return g(i - 1) * i;
}
}
private void button1_Click(object sender, EventArgs e)
{
int n = Convert.ToInt32(textBox1.Text);
textBox2.Text = f(n).ToString();
}