Powerball

Feeling lucky?

The odds of winning the Powerball jackpot are 1 in 292,201,338. But someone has to win, right? To play Powerball, the rules are simple. Choose 5 numbers between 1 and 59, and then choose another number between 1 and 35 (the "Powerball").

Randomness in JavaScript

In a game of chance it's crucial to generate random numbers.

Unfortunately, it’s actually very hard to create a truly random value (unless you have access to some radioactive material, or a monkey with a keyboard, or even a bunch of lava lamps). To get around this, programming languages use deterministic methods to produce pseudo-random numbers. These are numbers that appear to be random, but are actually generated by functions that accept seed values based on events such as the time or position of the mouse pointer.

JavaScript has the random function, which is a method of the built-in Math object. All the major browsers currently use the xorshift128+ algorithm in the background to generate a pseudo-random number.

The Powerball logo

Coin Flipping

What does the result of 80,000 coin flips look like? Something like:

Inspired by Nate Silver, Random numbers determined