Most of the HP 20s features can be used in Program mode just like they are used manually. Following are two sample programs for the HP 20s.
hpsupportheadportlet
Actions ${title}
Loading...
Welcome to HP Customer Support
hpcontactsecondarynavigationportlet
Actions ${title}
Loading...
hpherosupportsearch
Actions ${title}
Loading...
hpshareprintwidgetportlet
Actions ${title}
Loading...
hpconcentrawrapperportlet
Actions ${title}
Loading...
HP 20s Calculator  Programming
Calculator symbol key
The procedures in this document use the following text to represent symbol keys:
Key

Description

Text Representation


Right shift key

RS


Leftshift key

LS


Square root key

SQx

Pythagorean theorem
To illustrate how STO and RCL are used to recall data from registers in a program, enter the following Pythagorean theorem program. It calculates the length of the hypotenuse (side c) of a right triangle, given the lengths of sides a and b. The formula used is in Figure 1. Assume that the calculation begins with side a in R^{1} and side b in R^{2}.
Figure : Pythagorean formula
Keys

Display

Description

Press LS, then PRGM

Enters Program mode.


Press RS, then CLPRGM

00

Clears program memory. (Skip this step to leave programs intact.)

Press RS, LBL, then E

01 61 41 E

Labels program "E".

Press RCL, then 1

02 22 1

Recalls a from R^{1}

Press LS, then ^{2}

03 51 11

a^{2}

Press +

04 75
 
Press RCL, then 2

05 22 2

Recalls b from R^{2}.

Press LS, then x^{2}

06 51 11

b^{2}

Press =

07 74

a^{2}+ b^{2}

Press SQx

08 11


Press RS, then RTN

09 61 26
 
Hold LS and SHOW

3902

Checksum (see Checksum below)

Press LS, then PRGM

Exits Program mode.

Now store the a and b values of 22 and 9 into R^{1} and R^{2}, then run the program:
Keys

Display

Description

Press 22, STO, then 1

22.0000

Stores a in R^{2}

Press 9, STO, then 2

9.0000

Stores b in R^{2}

Press XEQ, then E

23.7697

Length of the hypotenuse.

Random number generator
The following program generates random numbers in the range 0 < r^{1}< 1. The program uses a starting value between 0 and 1. For a different sequence of random numbers, use a different starting value.
note:
The program uses the algorithm: r^{1}+ 1 = FP (997r^{i}t>), where r^{0} is a starting value between 0 and 1 (for example, 0.5284163). The random number generator passes the chisquare frequency tests for uniformity, and the serial and run tests for randomness. The most significant digits are more random than the least significant digits. If the starting value is between 0 and 1, and if the starting value x 10^{7} is not divisible by 2 or 5, then the generator produces 500,000 different random numbers before repeating.
Keys

Display

Description

Press LS, then PRGM

Enters Program mode.


Press RS, then CLPRGM

00

Clears program memory. (Skip this step to leave programs intact.)

Press RS, LBL, then A

01 61 41 A

Names program "A".

Press RCL, then 0

02 22 0

Get r_{I}.

Press x

03 55

Multiplies ...

Press 9

04 9
 
Press 9 again

05 9
 
Press 7

06 7

... by 997

Press =

07 74

Equals 997.
r_{I}

Press RS, then FP

08 61 45

r_{I}+ 1 = FP (997r_{I})

Press STO, then 0

09 21 0

Saves r_{I} + 1

Press RS, then RTN

10 61 26

Ends program

Hold LS and SHOW

7Ab8

Checksum (see Checksum below)

Press LS, then PRGM

Exits Program mode.

To store the starting value in R^{0} and run the program:
Keys

Display

Description

Press .5284163

0.5284163_

Enters starting value in display.

Press STO, then 0

0.5284

Stores starting value in R_{0}

Press XEQ, then A

0.8311

Generates first random number.

Press XEQ, then A again.

0.5579

Generates second random number.

Continue pressing XEQ, then A to continue generating random numbers.
To scale the random numbers to within the range lower limit < R_{i}upper limit, add program lines to multiply the random number by the difference between the limits, and add the product to the lower limit. That is:
scaled R_{i} = (upper limit  lower limit)r^{i}+ lower limit
Checksum
After a program is entered, check to see if the keystrokes are entered correctly by comparing the checksum listed in this document to the checksum created by the program. The checksum is a unique hexadecimal value assigned to the specific keystrokes entered. To view the checksum, press and hold LS and SHOW for a moment while in Program mode.
hpfeedbackinputportlet
Actions ${title}
Loading...
hponlinecommunitiesportlet
Actions ${title}
Loading...
Ask the community!
hpfeedbackbannerportlet
Actions ${title}
Loading...
hpcountrylocatorportlet
Actions ${title}
Loading...
Country:
United States
hpdetectloadmydeviceportlet
Actions ${title}
Loading...