Skip to content
Robin Haberkorn edited this page Nov 24, 2024 · 1 revision

Here's a port of the infamous PI.TEC by Stanley Rabinowitz according to "A Spigot Algorithm for the Digits of Pi", American Mathematical Monthly 102 (1995) 195-203. It only required some minor changes like replacing B with 0, adding braces due to SciTECO's operator precedence, discarding values at the end of If-statements and outputting via = as long as ^T is not implemented. I have also adapted the "coding style" to be closer to other SciTECO macros, although this was entirely optional.

\Un Qn"= 20Un ' 0Uh 0Uv HK
Qn< J 0Uq Qn*10/3Ui
Qi< (\+2)*10+(Qq*Qi)Ua 0L :K$ Qi*2-1Uj Qa/QjUq
Qa-(Qq*Qj)-2\ 10@I// -%i >
Qq/10Ut Qh+Qt+48Uw Qw-58"= 48Uw %v$ ' Qv"N Qv-^^0= ' QwUv Qq-(Qt*10)Uh >
Qv-^^0=
-EX

It can be called with sciteco -m pi.tec <n>, whereas n is the number of digits to calculate (20 by default).