The most common way to generate a random number is the linear congruential generator (https://en.wikipedia.org/wiki/Linear_congruential_generator). Even though it doesn’t give very good results and is obsolete a lot of people still use it because it is simple. Many programming languages (gcc, Java, Delphi, Visual Basic, Visual C++) still use/used it as their default.
First you generate a seed, which is either the current time in seconds or time since the computer booted in seconds.
Then you do the formula:
seed = (a * seed + c) % m
Seed becomes you new random number. Java for examples uses the values a = 25214903917 c = 11 m = 2^48
Latest Answers