IT lexicon › Programming › Middle-square method

Middle-square method

Programming På svenska → Updated: 2026-08-07

Von Neumann's fast and knowingly sinful way of squeezing random numbers out of a computer.

The middle-square method is an early pseudorandom number generator proposed by John von Neumann around 1946: square a seed, take the middle digits as the next number, and repeat. It was needed for Monte Carlo simulations on ENIAC, where Stanisław Ulam and von Neumann were computing neutron diffusion for Los Alamos.

Von Neumann knew the method was poor — sequences easily fall into short cycles or collapse to zero — but chose it because it was fast and reproducible, letting whoever was debugging re-run exactly the same "randomness." His famous objection was to the principle itself: "anyone who considers arithmetical methods of producing random digits is, of course, in a state of sin." The method is unusable today, but it marks the start of random numbers computed by a machine.

← Back to the lexicon