Post Reply 
(11C) Roll "Four" Dice at Random
10-15-2018, 07:48 AM
Post: #7
RE: (11C) Roll "Four" Dice at Random
(10-14-2018 09:55 PM)Dieter Wrote:  Also the RCL I and R↑ are no required. Just do it as simple as can be:

If only the sum of the dice is needed we can follow your suggestion from an older post:
(05-02-2018 08:03 PM)Dieter Wrote:  I just noticed you can save even two more steps if you remove both the CLX and the RCL+1. ;-)

Code:
LBL D
4
STO I
LBL 4
RAN#
6
x
INT
+
DSE
GTO 4
RTN



However if you want to use RAN# only once as suggested by
(05-02-2018 05:06 AM)Joe Horn Wrote:  THE QUESTION: Is there a direct way to return the sum of a roll of N dice without generating N random numbers and adding them together?

… you can use this translation of my program for the HP-42S:
Code:
001▸LBL D
002 6
003 x<>y
004 yˣ
005 LSTx
006 x<>y
007 RAN#
008 ×
009 INT
010 +
011 0
012▸LBL 0
013 LSTx
014 x=0
015 GTO 1
016 6
017 ÷
018 INT
019 +
020 GTO 0
021▸LBL 1
022 R↓
023 5
024 ×
025 -
026 RTN

Just be aware that you have to enter the number of dice (here 4) prior to running the program:

4
GSB D

Cheers
Thomas
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
(11C) Roll "Four" Dice at Random - Gamo - 10-13-2018, 03:32 AM
RE: (11C) Roll "Four" Dice at Random - Thomas Klemm - 10-15-2018 07:48 AM



User(s) browsing this thread: 5 Guest(s)