HP Program Pascals Triangle

HP program for pascal's triangle printout
HP program for pascal’s triangle printout

HP program for Pascals Triangle

Just recently I had to help my daughter with some algebra homework and I remembered the Pascal’s Triangle in order to calculate the binomial coefficients. I wanted to write a small HP program on my HP28S to come up with a fast solution. I am not explaining the program at this point but all the steps you need to know to create this program on your own HP28S.
There a just a few things you have to know:

  • How to create, name, store and delete a program
  • How to edit and move around in a program
  • Run and Print the program if you have a printer

Create the HP program

We start out with creating the program by pressing “<<“

HP button to start a program
HP button to start a program

Next we want to read what is on last line of the screen and store it into a variable, we do this by entering “->” or shift-U followed by the variable name N. We now enter again the “<<” to tell the program to start here.
Notes:

  • Make sure you all all the spaces as shown in the program printout
  • The word “FOR” can be found here: BRANCH or shift-N then NEXT
  • “DUP” can be found here: STACK or shift-G
  • “NEXT” can be found here: BRANCH or shift-N then NEXT
  • “->LIST” can be found here: STACK or shift-G then NEXT

Name, Store and delete the program

There is no need to enter to enter the last two “>>”, so just hit “ENTER” after “->LIST”. You now have the program on the screen.
You now give the program a name, I will call it “PDREI”.
So what you do is use the ” ‘ ” see below above the STO-button and enter your program name ‘PDREI and press ENTER. (no need for the closing ” ‘ “, your HP will do this on it’s own)
Now all you need to do is press the STO button and the program will be stored.
To delete or purge the program:
Start by ” ‘ ” and the program name, then press PURGE or shift-4

VISIT and STO button HP28S
VISIT and STO button HP28S

Edit a program

Press the “USER” button to show your programs
Now press ” ‘ ” followed by the program name (no spaces) and then press VISIT
Press INS or DEL for insert or delete mode when typing
Press the arrow keys to navigate in your program
When finished just press the ENTER button
If you want to cancel, just press the ON button

Run and Print the program

Run the program:
Press the “USER” button to get to the User Menu
Now enter for example the number 5, then click your program name PDREI in the User menu, you will see the following output: { 1 5 10 10 5 1 }
Print the program:
First show the Print Menu by pressing PRINT or shift-L
Press ” ‘ ” followed by the program name and press the menu button PRVAR
Print the screen output, go to the PRINT menu and select PRLCD

Print Friendly, PDF & Email

Permanent link to this article: https://www.teawea.com/hp-program-pascals-triangle/

Leave a Reply

Your email address will not be published.