Hi there;
I want to make program that show me ,how long I need to wait for my lucky day.
I want to select only 1 combination ,let say numbers 15,25,35,45,55 .
Program will compare my numbers with random numbers , if find it program stop.
I assume draw is 2 x per week ,if year has 52 weeks x 2 there is 104 draws per year .
I made this code ,but it does not work ,I don't know how to make it .
Thanks
int n[5]; // num combination;
int a, b, c, d, e;
int year = 104;
int num = 1;
int w = 1;
For a Mega Millions ticket you choose 5 numbers from 1 to 70, without duplicates.
There is also a separate Multiplier number from 1 to 25.
70 choose 5 is 12103014.
So on average it takes that many tickets to win.
With 104 tickets a year that's 12103014 / 104, about 116375 years.
The program should only take a few seconds, though.
But to win the biggest prize you have to hit the multiplier, too.
So that's 12103014 * 25 = 302575350.
302575350 / 104 is about 2909378 years.
The program should take on average 25 times longer than before.
You've misunderstood the question. He wants to simulate playing the same ticket (e.g., 15,25,35,45,55) for every draw of the Mega Millions Lottery. Supposing 2 draws per week, how many years will he have to wait before he hits the jackpot.
Also, he seems to have forgotten/misunderstood that the biggest jackpot requires not only hitting the main five numbers but also hitting another separate number from 1 to 25.
The answer is on average he will wait 116375 years to hit the main five numbers and 2909378 years to hit the main five numbers and the bonus (so-called "multiplier") number.