Post Reply 
Mini-challenge: Fast F(93) on HP-16C
08-07-2023, 11:48 AM (This post was last modified: 08-07-2023 01:44 PM by MarkB.)
Post: #9
RE: Mini-challenge: Fast F(93) on HP-16C
Here is my attempt. I don't have a 16C and am patiently waiting for my 15C CE. I've tried it on the Jovial RPN emulator and without changing the speed setting, it took about 15s for F(93).

It is based on the fact that:
F(0) = 0
F(1) = 1
F(2n) = F(n)(2F(n+1) - F(n))
F(2n+1) = F(n+1)^2 + F(n)^2

I've taken inspiration for this solution from this description.

For input larger than 93, it will just turn on the "G" flag.

I've never used a 16C before so not sure if this is particularly good code, but here it is anyway.

Code:

001 LBL A
002 1
003 X<>Y
004 X>Y?
005 GTO 0
006 RTN
007 LBL 0
008 9
009 4
010 X>Y?
011 GTO 1
012 X<>Y
013 SF 5
014 RTN
015 LBL 1
016 X<>Y
017 STO 0
018 0
019 STO 1
020 STO 3
021 1
022 STO 2
023 1
024 2
025 8
026 STO 4
027 LBL 2
028 RCL 4
029 SR
030 STO 4
031 RCL 0
032 AND
033 X=0?
034 GTO 2
035 LBL 3
036 RCL 4
037 X=0?
038 GTO 5
039 RCL 2
040 SL
041 RCL 1
042 -
043 RCL 1
044 x
045 STO 5
046 RCL 1
047 RCL 1
048 x
049 RCL 2
050 RCL 2
051 x
052 +
053 STO 2
054 RCL 5
055 STO 1
056 2
057 RCL 3
058 x
059 STO 3
060 RCL 0
061 RCL 4
062 AND
063 X=0?
064 GTO 4
065 RCL 1
066 RCL 2
067 +
068 STO 2
069 LSTx
070 STO 1
071 1
072 RCL 3
073 +
074 STO 3
075 LBL 4
076 RCL 4
077 SR
078 STO 4
079 GTO 3
080 LBL 5
081 RCL 1
082 RTN
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: Mini-challenge: Fast F(93) on HP-16C - MarkB - 08-07-2023 11:48 AM



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