Do you really expect this to terminate in a (reasonably) finite amount of time?
So only about 3 trillion passes through those nested loops that you wanted. Instead, why not consider how you might interpret the following:
conv(ones(1,6)/6,ones(1,6)/6)
ans =
0.027778 0.055556 0.083333 0.11111 0.13889 0.16667 0.13889 0.11111 0.083333 0.055556 0.027778
Can a similar idea be used to find the distribution of the sum of 16 fair dice? (Yes, and it will take little time to run too.)
Ok, maybe the above was not sufficiently clear. So will this help?
format rat
conv(ones(1,6)/6,ones(1,6)/6)
ans =
1/36 1/18 1/12 1/9 5/36 1/6 5/36 1/9 1/12 1/18 1/36
Think about it. How would you extend that to work for 3 dice? 4 dice? 16 dice? Brute force is rarely a good idea for a homework assignment.
Best Answer