Yet another Fibonacci mini-challenge (HP-42S/Free42)
01-09-2019, 05:20 AM
Post: #21
 Gerson W. Barbosa Senior Member Posts: 1,473 Joined: Dec 2013
RE: Yet another Fibonacci mini-challenge (HP-42S/Free42)
(12-06-2018 11:30 AM)Thomas Okken Wrote:  NOT +/-

That's actually three bytes, not two, but 1 BASE+ is four bytes, so it does save one byte.

Anyway, now I see why this cleverness causes this implementation to fail for n > 50: that's where the BASE functions' 36-bit arithmetic goes out of range. You do need to use IP if you want to avoid that limitation.

1 + IP takes an extra step. However, we could use IP and save one step instead:

Code:
 00 { 23-Byte Prgm } 01▸LBL "FIB" 02 0.5 03 ASINH 04 × 05 COSH 06 0.8 07 SQRT 08 × 09 IP 10 END

This even works for F0. Too bad the working range is from n=0 through n=26 on the actual 42S. On Free42 it’s even worse: it will fail for n=1, because IP(0.99999999999999999999...99) is of course zero. IP can be replaced with RND, provided the display mode is set to FIX 0 or FIX 1, definitely not a good idea.

But the limitation can still be overcome by using IP while keeping the original number of steps:

Code:
 00 { 24-Byte Prgm } 01▸LBL "FIB" 02 0.5 03 ASINH 04 × 05 COSH 06 0.8 07 SQRT 08 × 09 →HR 10 IP 11 END

The range on the real 42S is still limited to [1..50], but on Free42 is about [1..160+] (to be checked).
 « Next Oldest | Next Newest »

 Messages In This Thread Yet another Fibonacci mini-challenge (HP-42S/Free42) - Gerson W. Barbosa - 12-05-2018, 12:59 AM RE: Yet another Fibonacci mini-challenge (HP-42S/Free42) - Didier Lachieze - 12-05-2018, 02:07 AM RE: Yet another Fibonacci mini-challenge (HP-42S/Free42) - Gerson W. Barbosa - 12-05-2018, 02:35 AM RE: Yet another Fibonacci mini-challenge (HP-42S/Free42) - Gerson W. Barbosa - 12-05-2018, 03:12 AM RE: Yet another Fibonacci mini-challenge (HP-42S/Free42) - Thomas Klemm - 12-05-2018, 03:15 AM RE: Yet another Fibonacci mini-challenge (HP-42S/Free42) - Gerson W. Barbosa - 12-05-2018, 04:14 PM RE: Yet another Fibonacci mini-challenge (HP-42S/Free42) - Thomas Okken - 12-06-2018, 01:46 AM RE: Yet another Fibonacci mini-challenge (HP-42S/Free42) - Gerson W. Barbosa - 12-06-2018, 02:02 AM RE: Yet another Fibonacci mini-challenge (HP-42S/Free42) - Thomas Klemm - 12-05-2018, 03:22 AM RE: Yet another Fibonacci mini-challenge (HP-42S/Free42) - Thomas Okken - 12-06-2018, 03:15 AM RE: Yet another Fibonacci mini-challenge (HP-42S/Free42) - Gerson W. Barbosa - 12-06-2018, 11:04 AM RE: Yet another Fibonacci mini-challenge (HP-42S/Free42) - Thomas Okken - 12-06-2018, 11:30 AM RE: Yet another Fibonacci mini-challenge (HP-42S/Free42) - Gerson W. Barbosa - 12-06-2018, 12:31 PM RE: Yet another Fibonacci mini-challenge (HP-42S/Free42) - Gerson W. Barbosa - 01-09-2019 05:20 AM RE: Yet another Fibonacci mini-challenge (HP-42S/Free42) - Thomas Klemm - 12-07-2018, 10:42 AM RE: Yet another Fibonacci mini-challenge (HP-42S/Free42) - Gerson W. Barbosa - 12-07-2018, 03:41 PM RE: Yet another Fibonacci mini-challenge (HP-42S/Free42) - pier4r - 12-07-2018, 06:31 PM RE: Yet another Fibonacci mini-challenge (HP-42S/Free42) - Gerson W. Barbosa - 12-07-2018, 10:49 PM RE: Yet another Fibonacci mini-challenge (HP-42S/Free42) - Valentin Albillo - 12-08-2018, 12:31 AM RE: Yet another Fibonacci mini-challenge (HP-42S/Free42) - Gerson W. Barbosa - 12-08-2018, 01:11 AM RE: Yet another Fibonacci mini-challenge (HP-42S/Free42) - Thomas Klemm - 12-07-2018, 08:04 PM

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