The linear congruential generator
JAEV Notes · October 2026 · 3 min read
A linear congruential generator is a simple, long-used way for a computer to produce numbers that look random. It takes a number, multiplies it by a constant and adds another constant, then divides by a third and keeps only the remainder. That remainder is the next number, and the rule is applied to it again.1 The mathematician D. H. Lehmer described the form without addition in a paper given in 1949 and printed in 1951; W. E. Thomson and A. Rotenberg published the form with addition in 1958.1, 2
How it works
Written as a formula: next = (a × x + c) mod m, where the first x is the seed. Every number lies between 0 and m − 1. Dividing by m turns it into a fraction between 0 and 1, which a program can scale to any range it needs.1
The computer-art pioneer Georg Nees used the simplest version. His dissertation calls the method "extremely simple": multiply by 5 and keep the remainder after dividing by 2³¹.3 The same generator decided the shifts and turns of the squares in his Schotter.3 To explain it, Nees used a small version that keeps the remainder after 128, which repeats after 32 numbers.3 Started from 1, it gives 1, 5, 25, 125, 113, 53 and so on; the left half of the picture above draws that loop.
Why it repeats
There are only m possible remainders, so sooner or later a number comes back and the sequence repeats. With an added constant and well-chosen values, a generator can run through all m numbers before that happens.1 Nees called a generator with a short period "almost always unsuitable" for his work; the period, he wrote, must be so long that "we do not notice it".3
The pattern inside
The numbers are not independent. If each number and the next are drawn as a point, the points fall on a limited number of straight lines, and in three dimensions on planes.1 With the multiplier 5 the reason is plain: the next number is 5x minus 0, 1, 2, 3 or 4 times the modulus, so every pair lies on one of five lines (right half of the picture).
The structure is always there: for any constants, the points lie on at most a certain number of planes, so choosing the constants is a matter of making that number large.1 These generators must not be used where secrecy matters, as in cryptography.1
Still in use
Java's standard class java.util.Random uses "a linear congruential formula" on a 48-bit number.4 Processing, the language many generative artists learned on, gets its random() from that class, so a sketch that calls randomSeed() is in effect setting the seed of a linear congruential generator.5
JAEV's exhibition Content takes its chance from a hash instead: it turns a text into a long number, so that "the same text always gives the same work"; see the note on SHA-256 as a source of chance.6
Sources
- “Linear congruential generator”. Wikipedia
The recurrence with multiplier a, increment c and modulus m; “The Lehmer generator was published in 1951”, the LCG “in 1958 by W. E. Thomson and A. Rotenberg”; Hull–Dobell theorem; points on hyperplanes; low bits; “must not be used, for cryptographic applications”. - “Lehmer random number generator”. Wikipedia
X(k+1) = a · X(k) mod m; Lehmer, “Mathematical methods in large-scale computing units” (1949, published 1951); power-of-two modulus: “the period is at most m/4”, seed odd, a ≡ ±3 (mod 8); Park and Miller 1988, m = 2³¹ − 1, a = 16807, “Random Number Generators: Good Ones Are Hard To Find”; 48271 in 1993. - Zellyn Hunter, “Schotter – Georg Nees – Part 2”, 2024
Nees: “The method we will use to generate random numbers is extremely simple”; multiply by 5, remainder modulo 2³¹; toy version modulo 128 with a 32-number period; “random generators with such a short period as the algorithm presented here are almost always unsuitable for our investigations”; the period must be long enough that “we do not notice it”. - “Class Random”. Java Platform SE 8 API documentation, Oracle
“The class uses a 48-bit seed, which is modified using a linear congruential formula.” Multiplier 0x5DEECE66D, addend 0xB. - PApplet.java, Processing 4 source code. GitHub
random() calls internalRandom.nextFloat(), where internalRandom = new Random() (java.util.Random); randomSeed() calls internalRandom.setSeed(seed). - “Content”, JAEV. JAEV, Lund
“The text is turned into a fingerprint, a long number that changes completely if a single character changes. … The same text always gives the same work.”
- Published
- JAEV Notes, October 2026.
- Use
- Text CC BY 4.0. Free to use and quote with credit to JAEV and a link to this page. Images and quotations by others keep their own terms.
All texts as one file: archive.json - Cite
- JAEV Notes, “The linear congruential generator”, jaev.gallery/notes/linear-congruential-generator/, 2026.
- Corrections
- Additions and corrections are welcome: info@jaev.gallery
- Share
A link from your own site, course page or reading list helps others find it.- Follow
- New notes by RSS · Instagram · Bluesky
JAEV is a daemon taking shape: machines, weights, room, brain.