Sum of roll of N dice
|
05-02-2018, 02:00 PM
Post: #9
|
|||
|
|||
RE: Sum of roll of N dice
(05-02-2018 12:03 PM)Joe Horn Wrote: <scampers off gleefully to code it> In CAS view of the HP Prime, this can be implemented in one line. Caution: "convert" must be typed in lowercase or it won't work. sum(convert(RANDINT(6^N-1),base,6))+N Unfortunately, this only works up to N=18. The following brute-force sum of N random rolls (which is what I was trying to avoid) works up to N=10000: sum(RANDINT(N,1,6)) ... and it's plenty fast. It returns the sum of 10000 dice rolls in 0.0845 seconds, which is a tad faster than the HP-11C program. <0|ΙΈ|0> -Joe- |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 2 Guest(s)