Percentages and Math

LCG Random Sequence Calculator

Enter the modulus, the multiplier, the increment and a seed.

Your numbers

A whole number up to 9,007,199,254,740,991. Example values throughout.

Up to 200.

Result

Period

16

Full period: every value from 0 to 15

Steps before the cycle starts
0
Hull-Dobell test
Passes

Terms

TermValue
x07
x16
x21
x38
x411
x510
x65
x712
x815
x914
x109
x110
x123
x132
x1413
x154

Full-period test (Hull-Dobell)

Hull-Dobell conditionHolds
c and m share no factorYes
a - 1 divisible by 2Yes
a - 1 divisible by 4 (m is)Yes
How this was calculated
  1. Each term is x(n+1) = (a x(n) + c) mod m.
  2. The period is found by following the sequence until a value repeats, using Brent's cycle search, which needs no memory for the values.
  3. Hull-Dobell: with c > 0 the period is m for every seed exactly when c and m share no factor, a - 1 is divisible by every prime factor of m, and by 4 if m is. The test is shown for reference even when c is 0, when it cannot pass.
  • A linear congruential generator is easy to predict. It is fine for teaching and simple simulations but not for passwords, keys or anything that must resist guessing.

Calculated using SumPanda.com · https://sumpanda.com/lcg-random-sequence-calculator/

Results are estimates for general information. Verify important figures before relying on them.

Next step

How to use the lcg random sequence calculator

  1. Enter the modulus m, the multiplier a, the increment c and the seed.
  2. Enter how many terms to list.
  3. Read the period, whether the generator reaches every value, and the first terms.
  4. Try the presets to compare a full period setting with a poor one.

Formula

Next value = (a x current value + c) mod m

Full period needs: c and m share no factor other than 1

a - 1 is divisible by every prime factor of m

a - 1 is divisible by 4 when m is divisible by 4

These three conditions are the Hull and Dobell theorem. When they hold, the sequence visits every value from 0 to m - 1 before repeating.

m = 16, a = 5, c = 3, seed 7

The terms are 7, then (5 x 7 + 3) mod 16 = 6, then 1, then 8, and so on. The period is 16, which is the full range, so all of the numbers from 0 to 15 appear once before the cycle repeats. The tool confirms that the Hull and Dobell test passes.

Changing to a = 4 and c = 2 with seed 1 gives 1, 6, 10, 10, 10 and so on. The sequence gets stuck on 10 after a few steps, so the period is 1, and the Hull and Dobell test fails.

How a linear congruential generator works

An LCG makes each number from the one before it with a multiplication, an addition and a remainder. It is fast and needs very little memory, which made it popular in early software. The quality depends on the constants. A bad choice can have a short cycle or visible patterns, as the second example shows.

The period is the number of steps before the sequence starts to repeat. The tool finds it by a cycle detection method that works for large moduli without storing every value, and it also reports how many steps come before the cycle begins.

Do not use it for security

Because the next value is a simple function of the last, anyone who sees a few outputs can predict all the rest. LCGs are fine for simulations, games and teaching, and unsuitable for passwords, keys or anything an attacker might guess. The lowest bits of a power of two modulus are especially regular. For everyday random numbers see the Random Number Generator, and to test whether a sequence looks random try the Runs Test for Randomness Calculator. Other sequences are in the Collatz Sequence Calculator and the Arithmetic and Geometric Sequence Calculator.

Assumptions and limits

  • All values are whole numbers, and the modulus is at least 2.
  • Numbers up to 9,007,199,254,740,991 are handled exactly.
  • The constants shown are examples. Use the ones you want to study.
  • Up to 200 terms are listed, though the period is found for any size.

Formulas reviewed October 10, 2026. See the calculation methodology for how SumPanda rounds, tests and sources its formulas.

Frequently asked questions

What does full period mean?

The sequence visits each of the m possible values exactly once per cycle, so no value is skipped or repeated early.

Can the increment be zero?

Yes. That form is called multiplicative. It cannot reach a full period of m, because the value 0 would stay at 0.

Does the seed change the period?

With a full period setting no. With other settings the seed can lead to different cycles of different lengths.

Are the classic 32 bit constants good?

They reach the full period of 4,294,967,296 and are fine for simple uses, though far from the best modern generators.