Linear-feedback shift register (source code)

= Linear-feedback shift register
{wiki}

= LFSR
{c}
{synonym}

A binary linear-feedback shift register of degree $d$ updates a $d$-bit state by shifting and inserting a fixed linear combination over $\mathbb F_2$. With recurrence
$$
s_{n+d}=a_{d-1}s_{n+d-1}+\cdots+a_0s_n,
$$
its feedback polynomial is $x^d+a_{d-1}x^{d-1}+\cdots+a_0$.