What it does
Program contains a class called MyRNG which implements a simple Linear Congruential Generator.
Linear Congruential Generators are a simple formula to generate Pseudo-Random Numbers
The formula as as follows: Xn+1 = (aXn + c) mod m
The class contains a constructor with an optional seed parameter to determine the initial state of the generator. If no seed is provided than the seed will be automatically calculated using system time.
There is a next method which returns the next state. There is also a rand_int method similar to Python's random.rand_int(min, max) method. The rand_int method returns a scaled version of the next state to place your number within the desired range.
More information on Linear Congruential Generators at this wikipedia link https://en.wikipedia.org/wiki/Linear_congruential_generator
Note: I specicially chose the constant values for m, a, and c based on the constants used in glibc's implementation.
Log in or sign up for Devpost to join the conversation.