 19BII Program Question - Printable Version +- HP Forums (https://archived.hpcalc.org/museumforum) +-- Forum: HP Museum Forums (https://archived.hpcalc.org/museumforum/forum-1.html) +--- Forum: Old HP Forum Archives (https://archived.hpcalc.org/museumforum/forum-2.html) +--- Thread: 19BII Program Question (/thread-106817.html) 19BII Program Question - Hans van der Drift - 01-28-2007 Hello, I would like to ask for some help. I have some general knowledge of the solver and formulas but I am stumped on how (or if) to create a simple dice rolling equation. I am trying to create a solver function that will re-create the following. NUM DICE? = D HIT MIN? = H Number of hits = X So if I needed to recreate the rolling of 48 dice and show how many results are 5 and 6 cumulatively. or 32 dice and how many results are 4, 5 and 6 cumulatively. I saw a post from a guy that has done the on a TI-82. He used this formula. Quote: ClrHome --clear the screen 0->X --the variable x gets reset to 0, x will hold the # of successful hits Input ("Num Dice? ", D) --Prompts for # of dice to roll, stores the value in variable D Input ("Hit Min? ", H) --Prompts for Minimum number needed for a succesful hit, usually 4,5, or 6, and stores in Variable H) For (I,1,D,1) --This is a loop, the Variable I is our incrememted by 1 each time through until it is equal to D, which is the # of dice rolls If ((int (rand*6+1)>=H) --if the randomly generated number of 1-6 is greater than variable H, your minimum hit #, then... X+1->X --X, your hit count variable, gets incremented by 1 END --end the loop Disp X --print out the number of hits Quote: REPLACE THIS TEXT WITH THE QUOTE Re: 19BII Program Question - Marcus von Cube, Germany - 01-29-2007 This is a bit tricky but should work: ```HITS=SUM(I:1:DICE:1:MAX(0:SGN(INT(6xRAN#)+2-HMIN))) ``` Replace SUM by the summation sign (Sigma) ```INT(6xRAN#) returns an integer from 0 to 5 +2-HMIN converts it to a posive number if the margin is hit MIN(0:SGN()) returns a 1 if the argument is positive, 0 else ``` The summation sums up the ones that indicate a hit. Re: 19BII Program Question - Marcus von Cube, Germany - 01-29-2007 I just found out about the IF function: ```HITS=SUM(I:1:DICE:1:IF(INT(6xRAN#)+1