用c#工具编程,y=1/x+1/x^2+1/x^3……,直到最后一项小于10^-4为止.

来源:学生作业学帮网 编辑:学帮网 时间:2024/06/05 16:57:24

用c#工具编程,y=1/x+1/x^2+1/x^3……,直到最后一项小于10^-4为止.

double temp=1/x;
y=0;
while(temp>0.0001)
{
y+=temp;
temp*=temp;
}