06-18-2018, 03:56 AM
I'm trying to program the 1089 trick on HP-11C
This should be a good program to practice and learn RPN programing.
What it do is users input any three digits number in which numbers cannot contain repeated number like (222, 122, 444, 477, 339, etc.) These repeated numbers are not allowed.
Program take three digits numbers,
1. Reverse it
2. Subtracting the reversed number by the original number.
3. Result from steps two make a second reverse
4. Adding the result from its original number.
5. Out put should have 1089
Example:
Start with 532.
The Reverse is 235, and the difference is 532-235=297.
Reversing the difference gives 792, and 297+792=1089
The problem is there are 648 legitimate 3-digits numbers with no repeated digits and 136 of them produce 198 rather than 1089
My program will do any reversed digits and make sure that the top digits is larger than the second digits so that when subtracting the result will not be negative.
My reversed result cannot include 0 at the beginning of some specific digits when calculate result is 198 instead of 1089
Example: 132 reversed to 231 then 231-132=099 reverse to 990+099=1089
Program: 1089 Magic Trick
Gamo
This should be a good program to practice and learn RPN programing.
What it do is users input any three digits number in which numbers cannot contain repeated number like (222, 122, 444, 477, 339, etc.) These repeated numbers are not allowed.
Program take three digits numbers,
1. Reverse it
2. Subtracting the reversed number by the original number.
3. Result from steps two make a second reverse
4. Adding the result from its original number.
5. Out put should have 1089
Example:
Start with 532.
The Reverse is 235, and the difference is 532-235=297.
Reversing the difference gives 792, and 297+792=1089
The problem is there are 648 legitimate 3-digits numbers with no repeated digits and 136 of them produce 198 rather than 1089
My program will do any reversed digits and make sure that the top digits is larger than the second digits so that when subtracting the result will not be negative.
My reversed result cannot include 0 at the beginning of some specific digits when calculate result is 198 instead of 1089
Example: 132 reversed to 231 then 231-132=099 reverse to 990+099=1089
Program: 1089 Magic Trick
Code:
LBL A
STO 1
STO 2
GSB 1
RCL 1
RCL 2
X≤Y // Test for when top 3 digits is less than the bottom 3 digits then do the swap
GTO 2
RCL 2
PSE // Show the reversed of the original number
RCL 1
-
PSE // Show the result of the reversed number subtracted by original number
STO 2
STO 3
GSB 1
RCL 2
PSE // Show the reversed number of the result subtraction
RCL 3
+ // Show the final trick of 1089
RTN
-------------------------------------------------------------------------
LBL 2 // The pauses action below is the same as above
RCL 1
RCL 2
PSE
-
PSE
STO 2
STO 3
GSB 1
RCL 2
PSE
RCL 3
+
RTN
---------------------------------------------------------------------------
LBL 1 // Subroutine for digits reversal
STO-2
LBL 0
INT
10
STOx2
÷
FRAC
STO+2
LSTx
X≠0
GTO 0
RTN
Gamo