用C#写出s=1/1!-1/2!+1/3!+...+1/n!
来源:百度知道 编辑:UC知道 时间:2024/06/04 10:36:54
请高手多多指点,我要的是详细的过程。也就是一个可以执行的程序。谢谢。
using System;
class Test
{
// 计算阶乘
private double Factorial ( int n )
{
double rtn = 1;
while ( n > 1 )
{
rtn *= n -- ;
}
return rtn;
}
//计算s=1/1!-1/2!+1/3!+...+1/n!
public double Foo ( int n )
{
double rtn = 0 ;
while ( n > 0 )
{
rtn += 1/(Factorial(n--));
}
return rtn;
}
[STAThread]
static void Main(string[] args)
{
System.Console.WriteLine ( new Test().Foo( 5 ) );
}
}
很简单了,不用说什么了吧
用C#写出s=1/1!-1/2!+1/3!+...+1/n!
写出下列缩写形式的完整形式:1、it’s 2、what’s 3、isn’t 4、who’s 5、that’s 6、let’
S=1+1/2+1/3+1/4+...+1/100写出程序和画出程序框图
1S,2S,3S,4S,5S都是什么意思?有6S吗?
已知扇形的周长为20cm,《1》写出扇形的半径R与面积S的函数关系式S=f(R)
程序:1 10 100 1000 2 20 200 2000 3 30 300 300该怎样用C#写出来??
4S是什么?为什么叫4S而不叫3S,2S,1S呢?
写出四个中国的法定假期,如:It's on May the 1st,
C#如何实现C/S架构?
OA C# B/S 相关问题