
Create a program to continually calculate and output the next decimal digit of   



π


{\displaystyle \pi }

   (pi).

The program should continue forever (until it is aborted by the user) calculating and outputting each decimal digit in succession.

The output should be a decimal sequence beginning   3.14159265 ...



Note: this task is about   calculating   pi.   For information on built-in pi constants see Real constants and functions.



Related Task Arithmetic-geometric mean/Calculate Pi

go =>
  pi2(1,0,1,1,3,3,0),
  nl.
 
pi2(Q,R,T,K,N,L,C) =>
   if C == 50 then
      nl,
      pi2(Q,R,T,K,N,L,0)
   else
     if (4*Q + R-T) < (N*T) then
       print(N),
       P := 10*(R-N*T),
       pi2(Q*10, P, T, K, ((10*(3*Q+R)) div T)-10*N, L,C+1)
     else 
       P := (2*Q+R)*L,
       M := (Q*(7*K)+2+(R*L)) div (T*L),
       H := L+2,
       J := K+ 1,
       pi2(Q*K, P, T*L, J, M, H, C)
     end
   end,
   nl.