Advertisement
WarPie90

Untitled

Mar 16th, 2017
475
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Delphi 0.48 KB | None | 0 0
  1. Program Pi_Spigot;
  2. {$R-}
  3.  
  4. const
  5.   n   = 2000;
  6.   len = 10*n div 3;
  7.  
  8. var
  9.   i, j:Int32;
  10.   q, x: Int32;
  11.   a: array[1..len] of Int32;
  12.  
  13.   tm: Int64;
  14. begin
  15.   tm := GetTickCount();
  16.   for j := 1 to len do
  17.     a[j] := 2;
  18.  
  19.   for j := 1 to n do
  20.   begin
  21.     q := 0;
  22.     for i := len downto 1 do
  23.     begin
  24.       x    := 10*a[i] + q*i;
  25.       a[i] := x mod (2*i - 1);
  26.       q    := x div (2*i - 1);
  27.     end;
  28.   end;
  29.  
  30.   writeln('Used ' + ToStr(GetTickCount() - tm) + ' ms');
  31. end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement