Calculation of the Digits of π
by the Spigot Algorithm
of Rabinowitz and Wagon
(Faster Version)
The spigot algorithm of Rabinovitz and Wagon outputs sequentially the decimal digits of π one at a time. The basic idea of the algorithm however applies to other positional system. In particular, it was noted yet by Rabinovitz and Wagon themselves that the algorithm can be sped up by using the system in base, say, 10000. The digits in such a system are groups of 4 decimal digits so that in this variant the algorithm generates 4 decimal digits at a time: