lfsr prng

Run Settings
LanguagePython
Language Version
Run Command
def lfsr16(seed): state = seed % (1 << 16) while True: shifted_bit = (state & 1<<0) ^ (state & 1<<1)>>1 state >>= 1 if shifted_bit: state += 1 << 15 yield state def main(): rng = lfsr16(22222) for i, n in enumerate(rng, 1): if i > 100: break print(f'{n:05}', end=(' ' if i % 10 else '\n')) if __name__ == '__main__': main()
Editor Settings
Theme
Key bindings
Full width
Lines