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语句做,直接要答案.
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
//----------------------------