Challenge: Generate 24 in the X register / display
|
09-08-2020, 12:18 AM
(This post was last modified: 09-08-2020 12:19 AM by Fred Lusk.)
Post: #34
|
|||
|
|||
RE: Challenge: Generate 24 in the X register / display
I shortened my generic DM-42 program again. Now it is 10 steps. This program takes any single-digit number sitting in the X-register (or any number, positive, negative, or zero, for that matter), makes three copies in the stack (putting the number in X into Y and Z also), then uses all three numbers to create the number 24.
01 LBL "T4" 02 ENTER 03 ENTER 04 + 05 + 06 SIGN 07 RCL+ ST X 08 RCLx ST X 09 N! 10 END If you preload the stack with the same number in X, Y, and Z, then delete steps 02 and 03, which leaves an 8-step program. The following program will take ANY number in the X-register and convert it to 24. It works like the previous program, but it's simpler because it only has to deal with one number. 01 LBL "TF" 02 SIGN 03 RCL+ ST X 04 RCLx ST X 05 N! 06 END ...Fred |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 1 Guest(s)