Link to home
Start Free TrialLog in
Avatar of triffid1962
triffid1962

asked on

evaluating Pi

How would I solve this equation in a program? I know I need at least one FOR TO loop,but how would I do the fractions? I saw a question someone asked about fractions,but it doesn't seem to work.

 Pi/4= 1-1/3+1/5-1/7+1/9-1/11+.....

Avatar of Batalf
Batalf
Flag of United States of America image

Hi triffid1962

Could you explanin this mathematical function a little bit more and I would give you some code ASAP :-)

Maybe type down an example

Batalf
Hi triffid1962

Could you explanin this mathematical function a little bit more and I would give you some code ASAP :-)

Maybe type down an example

Batalf
Could this help you?

A saying says :
"We would need to compute five million terms just to get /4 to 6 (or 7) decimal places! "


var
  i : longint;
  pi : real;

begin
    pi:=1;
    for I:=3 to 5000000 step 4 do
    end;
        pi:=pi-(1/i);
        pi:=pi+(1/(i+2));
   end;
end.
Avatar of ozo
what doesn't seem to work?
In case the "step" command doesn't work


PROGRAM evaluatePI;
var
  i : longint;
  pi : real;

begin
    pi:=1;
    I:=3;
    repeat
        pi:=pi-(1/i);
        pi:=pi+(1/(i+2));
        i:=i+4;
    until i>=5000000;
    writeln(pi);
    pause;
end.
ASKER CERTIFIED SOLUTION
Avatar of Batalf
Batalf
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of triffid1962
triffid1962

ASKER

Ok  It'll do for now.I'll see what I can do with it.Thanks