suchislife
suchislife

Reputation: 1

Verifying Powerball® lottery odds to win. Why am I getting different odds than the official website advertises?

I know a little bit of Rust and I've decided to buy a Powerball ticket today just for fun. While checking the odds of winning, I figured why not see if I can verify them in Rust as a fun exercise. Well, this is where things got interesting. The thing is, the math seems to check. Or does it?

Context: Select five numbers between 1 and 69 for the white balls, then select one number between 1 and 26 for the red Powerball.

powerball_official_odds

Grand Prize - Match 5 + PB

This DOES calculate correctly.

// Match 5 + Powerball: 1 in 292,201,338
fn combinations(n: u64, r: u64) -> u64 {
    let mut result: u64 = 1u64;
    for i in 0..r {
        result = result * (n - i) / (i + 1);
    }
    result
}

fn main() {
    let white_balls_combinations: u64 = combinations(69, 5);
    let powerball_combinations: u64 = combinations(26, 1); // This is essentially just 26, as C(26,1) = 26
    let total_combinations: u64 = white_balls_combinations * powerball_combinations;
    println!("Total combinations possible: {}", total_combinations);
}

Rust Playground - Match 5 + Powerball

Prize - Match 5

This appears to calculate correctly but DOES NOT match the official website.

// Match 5: 1 in 11,238,513
fn combinations(n: u64, r: u64) -> u64 {
    let mut result: u64 = 1u64;
    for i in 0..r {
        result = result * (n - i) / (i + 1);
    }
    result
}

fn main() {
    let white_balls_combinations: u64 = combinations(69, 5);
    println!("Total combinations possible: {}", white_balls_combinations);
}

Rust Playground - Match 5

Prize - Match 4 + PB

This appears to calculate correctly but DOES NOT match the official website.

// Match 4 + Powerball: 1 in 22,477,026
fn combinations(n: u64, r: u64) -> u64 {
    let mut result: u64 = 1u64;
    for i in 0..r {
        result = result * (n - i) / (i + 1);
    }
    result
}

fn main() {
    let white_balls_combinations: u64 = combinations(69, 4);
    let powerball_combinations: u64 = combinations(26, 1); // This is essentially just 26, as C(26,1) = 26
    let total_combinations: u64 = white_balls_combinations * powerball_combinations;
    println!("Total combinations possible: {}", total_combinations);
}

Rust Playground - Match 4 + Powerball

Prize - Match 4

This appears to calculate correctly but DOES NOT match the official website.

// Match 4: 1 in 864,501
fn combinations(n: u64, r: u64) -> u64 {
    let mut result: u64 = 1u64;
    for i in 0..r {
        result = result * (n - i) / (i + 1);
    }
    result
}

fn main() {
    let white_balls_combinations: u64 = combinations(69, 4);
    println!("Total combinations possible: {}", white_balls_combinations);
}

Rust Playground - Match 4

Prize - Match 3 + PB

This appears to calculate correctly but DOES NOT match the official website.

// Match 3 + Powerball: 1 in 1,362,244
fn combinations(n: u64, r: u64) -> u64 {
    let mut result: u64 = 1u64;
    for i in 0..r {
        result = result * (n - i) / (i + 1);
    }
    result
}

fn main() {
    let white_balls_combinations: u64 = combinations(69, 3);
    let powerball_combinations: u64 = combinations(26, 1); // This is essentially just 26, as C(26,1) = 26
    let total_combinations: u64 = white_balls_combinations * powerball_combinations;
    println!("Total combinations possible: {}", total_combinations);
}

Rust Playground - Match 3 + Powerball

Prize - Match 3

This appears to calculate correctly but DOES NOT match the official website.

// Match 3: 1 in 52,394
fn combinations(n: u64, r: u64) -> u64 {
    let mut result: u64 = 1u64;
    for i in 0..r {
        result = result * (n - i) / (i + 1);
    }
    result
}

fn main() {
    let white_balls_combinations: u64 = combinations(69, 3);
    println!("Total combinations possible: {}", white_balls_combinations);
}

Rust Playground - Match 3

Prize - Match 2 + PB

This appears to calculate correctly but DOES NOT match the official website.

// Match 2 + Powerball: 1 in 60,996
fn combinations(n: u64, r: u64) -> u64 {
    let mut result: u64 = 1u64;
    for i in 0..r {
        result = result * (n - i) / (i + 1);
    }
    result
}

fn main() {
    let white_balls_combinations: u64 = combinations(69, 2);
    let powerball_combinations: u64 = combinations(26, 1); // This is essentially just 26, as C(26,1) = 26
    let total_combinations: u64 = white_balls_combinations * powerball_combinations;
    println!("Total combinations possible: {}", total_combinations);
}

Rust Playground - Match 2 + Powerball

Prize - Match 1 + PB

This appears to calculate correctly but DOES NOT match the official website.

// Match 1 + Powerball: 1 in 1,794
fn combinations(n: u64, r: u64) -> u64 {
    let mut result: u64 = 1u64;
    for i in 0..r {
        result = result * (n - i) / (i + 1);
    }
    result
}

fn main() {
    let white_balls_combinations: u64 = combinations(69, 1);
    let powerball_combinations: u64 = combinations(26, 1); // This is essentially just 26, as C(26,1) = 26
    let total_combinations: u64 = white_balls_combinations * powerball_combinations;
    println!("Total combinations possible: {}", total_combinations);
}

Rust Playground - Match 1 + Powerball

Match Powerball

This appears to calculate correctly but DOES NOT match the official website.

// Match Powerball: 1 in 26
fn combinations(n: u64, r: u64) -> u64 {
    let mut result: u64 = 1u64;
    for i in 0..r {
        result = result * (n - i) / (i + 1);
    }
    result
}

fn main() {
    let powerball_combinations: u64 = combinations(26, 1); // This is essentially just 26, as C(26,1) = 26
    let total_combinations: u64 = powerball_combinations;
    println!("Total combinations possible: {}", total_combinations);
}

Rust Playground - Match Powerball

Upvotes: 1

Views: 90

Answers (1)

John Kugelman
John Kugelman

Reputation: 362097

You'll need to account for having won a larger prize and exclude that possibility from the lower prizes.

For example, notice that the odds for just matching the Powerball number alone are 1 in 38.32. You're 1 in 26 to match the Powerball number, but 1 in 38.32 to do so and not match any of the five white balls.

Upvotes: 2

Related Questions