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+.....

triffid1962Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

BatalfCommented:
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
0
BatalfCommented:
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
0
BatalfCommented:
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.
0
Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

ozoCommented:
what doesn't seem to work?
0
BatalfCommented:
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.
0
BatalfCommented:
HI

Forgot pi:=pi*4 in the code :-)

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;
    pi:=pi*4 {forgot this one}
    writeln(pi);
    pause;
end.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
triffid1962Author Commented:
Ok  It'll do for now.I'll see what I can do with it.Thanks
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Pascal

From novice to tech pro — start learning today.