Maths & numbers

Linear feedback shift register period calculator

A linear feedback shift register evolves a binary state by shifting and appending an XOR feedback bit.

Your numbers

One to sixteen bits. The leftmost bit is emitted/discarded each step.
Distinct positions numbered from 1. XOR OLD tapped bits, shift left, append the result.

Calculated on your device. Your inputs aren’t sent to us.

Your result

Ready when you are

Enter your inputs and select Calculate.

Report an issue

Behind the numbers

How this calculation works

A linear feedback shift register evolves a binary state by shifting and appending an XOR feedback bit. This calculator follows the entire state orbit until its first repeat, separating any transient prefix from the eventual cycle. Taps are entered as positions from the left, and the update convention is printed explicitly so a claimed period can be reproduced rather than compared with an incompatible polynomial convention.

THE FORMULAs(t+1)=(s₂,…,s_w, XOR_(j in taps)s_j); orbit period=firstRepeatIndex−firstSeenIndex.

A worked example

For initial state 001 and taps 1,3, the states are 001,011,111,110,101,010,100 and then 001 again. There is no transient and the cycle period is seven. The feedback bit is calculated from the old state before shifting. Starting instead at 000 leaves the register at 000 forever, giving period one under the same taps.

Good to know

Initial states contain one to sixteen bits. Taps are distinct one-based positions within the state; at least one tap is required. The complete orbit is computed, but only its first 256 states and first 512 emitted bits are previewed. A full orbit can be downloaded. The output is not a secure random stream, a hardware timing simulation or a proof that a feedback polynomial is primitive.

Fix the update direction before interpreting the taps

Write the state left to right as s₁,…,s_w. The next state keeps s₂ through s_w and appends the XOR of the old tapped bits. The bit emitted at each step is old s₁. Thus position one refers to the bit being discarded, not the rightmost bit. Other references often use the reverse shift direction or attach taps to polynomial exponents.

Those conventions can describe related registers while showing different intermediate states or reciprocal characteristic polynomials. This calculator does not silently convert between them. To reproduce the worked example, use the exact initial word and numbered positions, then verify the next-state calculation one update at a time before comparing a full period.

Seven states form the default three-bit LFSR cycle001011111110101010100XOR old positions 1,3Preperiod = 0Period = 7
Under the left-shift and old-bit XOR convention, taps 1,3 map 001→011→111→110→101→010→100→001. The first state is already on the cycle, so preperiod zero and period seven.

The Second-order linear recurrence calculator evaluates a scalar numerical recurrence; this page follows a binary vector-state orbit through its first repeat.

A finite deterministic orbit may have a transient

Because there are only 2^w states, a repeat must occur after at most that many distinct states. Once a state repeats, all later states repeat too because the update is deterministic. The first occurrence of the repeated state marks the start of the cycle; states before it form the preperiod.

When the feedback omits information needed to invert the update, different old states can collapse to the same new state. Such a register can have a transient before entering its cycle. Assuming the initial state always lies on the final cycle would overstate the period. The table labels transient and cycle regions separately rather than using the number of visited states as the period.

A long cycle does not establish cryptographic security

A nonzero state of a maximal-period width-w binary LFSR can have period 2^w−1, while the zero state remains fixed. But many tap sets give shorter cycles, and the period can depend on the initial state. The engine checks the actual orbit for the supplied state instead of inferring a maximum from the width alone.

Linear feedback is predictable from sufficient output, even when the cycle is long and visually irregular. The displayed stream should therefore not be used for passwords, keys or security-sensitive randomness. Independent validation enumerates small registers directly, checks that each listed successor follows the stated XOR rule, and verifies the repeated-state indices used for the period calculation.

A few questions, answered

Why does the zero state have period one?

XOR of zero bits is zero, so shifting and appending zero leaves the all-zero state unchanged for any supported tap set.

Are the taps polynomial exponents?

No. They are positions numbered from the left of the entered state. Polynomial tap conventions vary, so translate a reference into the displayed update rule first.

Find your calculator

Start typing to explore the library.