
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

  ( pi
  =   f,q r t k n l,first
    .   !arg:((=?f),?q,?r,?t,?k,?n,?l)
      & yes:?first
      &   whl
        ' (   4*!q+!r+-1*!t+-1*!n*!t:<0
            & f$!n
            & (   !first:yes
                & f$"."
                & no:?first
              | 
              )
            & "compute and update variables for next cycle"
            & 10*(!r+-1*!n*!t):?nr
            & div$(10*(3*!q+!r).!t)+-10*!n:?n
            & !q*10:?q
            & !nr:?r
          |   "compute and update variables for next cycle"
            & (2*!q+!r)*!l:?nr
            & div$(!q*(7*!k+2)+!r*!l.!t*!l):?nn
            & !q*!k:?q
            & !t*!l:?t
            & !l+2:?l
            & !k+1:?k
            & !nn:?n
            & !nr:?r
          )
  )
& pi$((=.put$!arg),1,0,1,1,3,3)