Skip to content

Instantly share code, notes, and snippets.

@MaratB
Created July 19, 2012 18:58
Show Gist options
  • Save MaratB/3146001 to your computer and use it in GitHub Desktop.
Save MaratB/3146001 to your computer and use it in GitHub Desktop.
inference pi,Gregory's formula
program pi;
const c=0.5E-7;
var a,sum:real;
b:integer;
n:longint;
begin
a:=1.0;
sum:=1.0;
b:=-1;
n:=1;
repeat
a:=b/(2*n+1);
sum:=sum+a;
b:=-b;
n:=n+1
until
abs(a)<=c;
sum:=4*sum;
writeln('pi= ',sum);
end.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment