This commit is contained in:
Ingy döt Net 2013-06-05 21:47:54 +00:00
parent 1f1ad49427
commit 6f050a029e
2496 changed files with 37609 additions and 3031 deletions

29
Task/Pi/Erlang/pi.erl Normal file
View file

@ -0,0 +1,29 @@
% Implemented by Arjun Sunel
-module(pi_calculation).
-export([main/0]).
main() ->
pi(1,0,1,1,3,3,0).
pi(Q,R,T,K,N,L,C) ->
if C=:=50 ->
io:format("\n"),
pi(Q,R,T,K,N,L,0) ;
true ->
if
(4*Q + R-T) < (N*T) ->
io:format("~p",[N]),
P = 10*(R-N*T),
pi(Q*10 , P, T , K , ((10*(3*Q+R)) div T)-10*N , L,C+1);
true ->
P = (2*Q+R)*L,
M = (Q*(7*K)+2+(R*L)) div (T*L),
H = L+2,
J =K+ 1,
pi(Q*K, P , T*L ,J,M,H,C)
end
end.

39
Task/Pi/Seed7/pi.seed7 Normal file
View file

@ -0,0 +1,39 @@
$ include "seed7_05.s7i";
include "bigint.s7i";
const proc: main is func
local
var bigInteger: q is 1_;
var bigInteger: r is 0_;
var bigInteger: t is 1_;
var bigInteger: k is 1_;
var bigInteger: n is 3_;
var bigInteger: l is 3_;
var bigInteger: nn is 0_;
var bigInteger: nr is 0_;
var boolean: first is TRUE;
begin
while TRUE do
if 4_ * q + r - t < n * t then
write(n);
if first then
write(".");
first := FALSE;
end if;
nr := 10_ * (r - n * t);
n := 10_ * (3_ * q + r) div t - 10_ * n;
q *:= 10_;
r := nr;
flush(OUT);
else
nr := (2_ * q + r) * l;
nn := (q * (7_ * k + 2_) + r * l) div (t * l);
q *:= k;
t *:= l;
l +:= 2_;
incr(k);
n := nn;
r := nr;
end if;
end while;
end func;