Sum of roll of N dice
|
05-02-2018, 07:01 AM
(This post was last modified: 05-02-2018 07:05 AM by Jim Horn.)
Post: #4
|
|||
|
|||
RE: Sum of roll of N dice
Hello, Joe!
If you roll N six sided dice and put them next to each other and write down the values they show *minus 1* each, you'll get an N digit integer in base 6. All such 6^N integers are equally likely for fair dice. So, just find a random number from 0 to (6^N)-1, convert to base 6, add the sum of its digits plus N (to correct the "subtract 1 from each digit") and there you go: the sum of the six rolled dice with only one random number generation. Of course, converting an integer to base 6 will likely require a loop which can do the running sum of the base 6 integer as it goes (N iterations needed). But still only involves a single random number generation to get all N random dice thrown. |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 2 Guest(s)