Light 213 Posted June 7, 2017 Report Share Posted June 7, 2017 (edited) This is the problem: http://imgur.com/mKQlwIE I tried to make a program to simulate it here: http://imgur.com/a/YfCe8 But it's not working, the answer prints 0.0%... Any ideas what I did wrong? Edited June 10, 2017 by Light Quote Link to post Share on other sites
Agent P 2,480 Posted June 7, 2017 Report Share Posted June 7, 2017 My copy of yours kept alternating between 100 and 0. Declaring alto as a double datatype instead of int seems to have made it better but I really doubt the probability is 99.x% I'll try to figure it out by tomorrow but I can't guarantee anything. @FOX545 @Master Flap Quote Link to post Share on other sites
Echo 746 Posted June 8, 2017 Report Share Posted June 8, 2017 I tried running it on my machine and was getting huge numbers: atlo: 1410065128 141000% I realized it's because your if(prize >= 1){ atlo++; } is inside the for loop which runs a million times, thus for the first time in any lottery that n = 500 alto increases for every value of i after that up to a million. I changed a few things around and got more realistic values, but certain they're still incorrect. I don't have any more time at the moment to work on it, here's my code: 1 Quote Link to post Share on other sites
Shawnic 2,977 Posted June 10, 2017 Report Share Posted June 10, 2017 On 6/8/2017 at 10:11 AM, FOX545 said: I tried running it on my machine and was getting huge numbers: atlo: 1410065128 141000% I realized it's because your if(prize >= 1){ atlo++; } is inside the for loop which runs a million times, thus for the first time in any lottery that n = 500 alto increases for every value of i after that up to a million. I changed a few things around and got more realistic values, but certain they're still incorrect. I don't have any more time at the moment to work on it, here's my code: What makes you think the answer is still incorrect? (Have you calculated it manually? ) Quote Link to post Share on other sites
Light 213 Posted June 10, 2017 Author Report Share Posted June 10, 2017 it's a simple one line mathematical equation lol. 63.2% Quote Link to post Share on other sites
Agent P 2,480 Posted June 17, 2017 Report Share Posted June 17, 2017 So, what was the issue? Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.