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:

π/10 = .314159 ...
= 0 + 1/10000 (3141 + 1/10000 (5926 + 1/10000 (5358 + 1/10000 (9793 + 1/10000 ( ... ))))).

(The applet implements the algorithm as it is described by Arndt and Haenel with a 50,000 limitation on the number of decimal digits.)

This applet requires Sun's Java VM 2 which your browser may perceive as a popup. Which it is not. If you want to see the applet work, visit Sun's website at, download and install Java VM and enjoy the applet.

What if applet does not run?


  1. S. Rabinowitz, S. Wagon, A Spigot Algorithm for the Digits of π, The American Mathematical Monthly, Vol. 102, No. 3. (Mar., 1995), pp. 195-203.
  2. J. Arndt, C. Haenel, π Unleashed, Springer, 2000

Related material

  • What Is Algorithm?
  • Base (Binary, Decimal, etc.) Converter
  • Various sorting algorithms
  • Calculation of the Digits of pi by the Spigot Algorithm of Rabinowitz and Wagon
  • Euclid's Algorithm
  • Binary Euclid's Algorithm
  • Sieve of Eratosthenes
  • Ambassadors at a Round Table
  • Make It All Zeros
  • Algorithm for Computing the LCM
  • |Activities| |Contact| |Front page| |Contents| |Algebra| |Store|

    Copyright © 1996-2017 Alexander Bogomolny


    Search by google: