RPN Programming exercise (HP42S) Message #1 Posted by Gerson W. Barbosa on 23 Feb 2012, 7:45 p.m.
Given two fourdigit integer numbers on the stack, write an HP42S program that returns their product in no more than 20 seconds on a real HP42S.
Restriction: use no *, no BASE*, no /, no BASE/, no %, no MOD, no LN, no E^X, no LOG, no 10^X.
Currently I have two programs that meet the requirements:
00 { 77Byte Prgm }
01>LBL "MLTA"
...
29 ROTXY
...
35 END
and, since ROTXY has been allowed,
00 { 50Byte Prgm }
01>LBL "MLTB"
...
29 .END.
The latter has the advantage of being faster and shorter. Also, it accepts a wider range of nonfixed format operands.
Examples:
1234 ENTER 5678 XEQ MLTA > 7,006,652
9999 ENTER XEQ MLTA > 99,980,001
12 ENTER 3456789 XEQ MLTB > 41,481,468
1234 ENTER 5678 XEQ MLTB > 7,006,652
Gerson.
_{(7:57pm) Edited to add more restrictions:}
No STO*, no STO/, no Y^X.
_{Edited again (the LAST time) for yet one more restriction}
and no multiplication of any kind (except binary shifts).
Edited: 23 Feb 2012, 8:12 p.m. after one or more responses were posted
