Post Reply 
Programming exercise (RPL/RPN) - Reciprocal Fibonacci Constant
02-19-2017, 01:13 AM
Post: #31
RE: Programming exercise (RPL/RPN) - Reciprocal Fibonacci Constant
(02-17-2017 01:58 PM)Gerson W. Barbosa Wrote:  HP-50g (50 bytes)

« 0. 1. DUP2 5. ROLL

START SWAP OVER + ROT OVER INV + UNROT

NEXT DROP2

»



HP-48G (52.5 bytes)

« 0 1 DUP2 ROT 5 ROLL

START OVER + ROT
OVER INV + SWAP ROT

NEXT DROP2

»


HP-42S

00 { 28-Byte Prgm }
01>LBL "RFC"
02 0
03 0
04 1
05>LBL 00
06 +
07 LASTX
08 1/X
09 STO+ ST Z
10 X<> ST L
11 X<>Y
12 DSE ST T
13 GTO 00
14 RCL ST Z
15 .END.


HP-41

01>LBL 'RFC
02 0
03 0
04 1
05>LBL 00
06 +
07 LASTX
08 1/X
09 STO+ Z
10 X<> L
11 X<>Y
12 DSE T
13 GTO 00
14 RCL Z
15 .END.

A couple more HP 50g programs and another HP-42S RPN program (HP-41 compatible). No improvements here except perhaps for the lesser number of steps in the latter. The second HP 50g program is 2.5 bytes longer, but has one less instruction inside the loop. I think I've tried all possible stack-order combinations, but I can't break the 50-byte barrier (which doesn't mean it's not possible, of course).

HP-50g (50 bytes)

Code:
« 0. 1. DUP2 5. ROLL
  START UNROT PICK3 + 
DUP UNROT INV + UNROT
  NEXT DROP2
»


HP-50g (52.5 bytes)
Code:

« 0. 1. DUP2 ROT 5. 
ROLL
  START PICK3 + SWAP 
OVER INV + ROT
  NEXT ROT DROP2
»

HP-42S ( 28 bytes, excluding END )

Code:

00 { 28-Byte Prgm }
01>LBL "RFC"
02 0
03 RCL ST X
04 1
05>LBL 00
06 1/X
07 STO+ ST Y
08 X<> ST L
09 STO+ ST Z
10 X<> ST Z
11 DSE ST T
12 GTO 00
13 X<>Y
14 .END.



HP-41 ( 29 bytes, including END )

Code:

01>LBL "RFC"
02 0
03 RCL X
04 1
05>LBL 00
06 1/X
07 ST+ Y
08 X<> L
09 ST+ Z
10 X<> ST Z
11 DSE T
12 GTO 00
13 X<>Y
14 END
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: Programming exercise (RPL/RPN) - Reciprocal Fibonacci Constant - Gerson W. Barbosa - 02-19-2017 01:13 AM



User(s) browsing this thread: 1 Guest(s)