Lehmer PRNG LCG

I wrote a Ruby implementation of the Lehmer random number generator. It has a 128bit state and outputs 64bit values. According to Wikipedia it has a period of 2^126.

Cheers :-)

#!/usr/bin/ruby

class Lehmer

  LEHMULT=0x12e15e35b500f16e2e714eb2b37916a5

  def initialize(my_seed:)
    @@my_state=my_seed<<1|1
  end

  def next_hex
    @@my_state*=LEHMULT
    @@my_state%=(2**128)
    return (@@my_state>>64).to_s(16)
  end
end

a=Lehmer.new(my_seed: 1)

n_rounds=ARGV[0]==nil ? 1_000_000:ARGV[0].to_i

start_time=Time.now.to_i
n_rounds.times do
  a.next_hex
end
end_time=Time.now.to_i

puts a.next_hex

puts (end_time-start_time).to_s+' Seconds to run '+n_rounds.to_s+' iterations'

exit 0