Post Reply 
Programming exercise (RPL/RPN) - Reciprocal Fibonacci Constant
02-17-2017, 09:50 PM
Post: #15
RE: Programming exercise (RPL/RPN) - Reciprocal Fibonacci Constant
(02-17-2017 01:58 PM)Gerson W. Barbosa Wrote:  [font=Courier]HP-50g (50 bytes)

« 0. 1. DUP2 5. ROLL

START SWAP OVER + ROT OVER INV + UNROT

NEXT DROP2

»

Here's an alternative, using local variables and lists for readability:
Code:

« → N 
    «
     1 1
     3 N START DUP2 + NEXT
     N →LIST 
     INV ∑LIST
   »
»

I didn't measure on stock firmware since I have my calc with newRPL, but for comparison your code was 72 bytes in newRPL and the alternative is 80 bytes.
One glitch: it only works for N=3 and higher.
Just a different point of view.
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 - Claudio L. - 02-17-2017 09:50 PM



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