
Here the algorithm of the generator "Lottery Numbers" is described. With this random generator you can generate your lottery numbers. With a little luck you might already be the next millionaire.
Table of contents
What is randomness?
Randomness is an event whose state cannot be clearly predicted causally. This means that the result of a random generator may not be predictable or computable. This, however, contradicts the laws of each computer. In other words, a computer can not produce absolutely random numbers without additional peripherals. In this case we call it pseudo-random numbers. In general, you can philosophize about at which point you can actually speak about randomness in practise.
How are the lottery numbers generated?
Theoretically, several different methods are used in this generator to generate pseudo-random values. For the actual lottery numbers, a PHP function for cryptographically secure pseudo random numbers is used.
Random generators for binary string
How these random generators work, is explained here in detail.
Random generator for lottery numbers
The previous random number generators produce relatively good random numbers, which, however, can further be improved. The lottery numbers are therefore always generated on server-side with the PHP function random_int(), which generates cryptographically secure pseudo-random numbers:
// Intitialization for ($i = 1; $i <= $Number; $i++) { $numbers[] = $i; } // Select all lottery numbers for ($i = 1; $i <= $Subset; $i++) { $index = random_int(0, count($numbers) - 1); $lottery_numbers[] = $numbers[$index]; unset($numbers[$index]); // Delete entry $numbers = array_values($numbers); // Reset indexes }