pascal做1-1/3+1/5-1/7.前100项的和急,用for语句做,直接要答案.
来源:学生作业帮助网 编辑:六六作业网 时间:2024/12/19 17:32:07
pascal做1-1/3+1/5-1/7.前100项的和急,用for语句做,直接要答案.
pascal做1-1/3+1/5-1/7.前100项的和
急,用for语句做,直接要答案.
pascal做1-1/3+1/5-1/7.前100项的和急,用for语句做,直接要答案.
Program seq;
Var tmp: Double ;
Begin
tmp := 1.0;
For i:=1 to 99 do
tmp := tmp + 1.0/(2*i+1)*(((i+1) mod 2)-(i mod 2));
Writeln( "Resault = ", (tmp) );
Readln;
End.
//----------------------------
// 1 - 1/3 + 1/5 - 1/7 ...
//----------------------------
//输出结果:
//Resault = 0.78289822588964
//----------------------------
Program seq;
Var tmp: Double ;
Begin
tmp := -1.0;
For i:=1 to 99 do
tmp := tmp + 1.0/(2*i+1);
Writeln( "Resault = ", (-tmp) );
Readln;
End.
//----------------------------
// 1 - 1/3 - 1/5 - 1/7 ...
//----------------------------
//输出结果:
//Resault = -1.2843421893016
//----------------------------