(15C) Fibonacci Numbers
|
03-23-2017, 03:22 AM
(This post was last modified: 03-23-2017 01:09 PM by Eddie W. Shore.)
Post: #1
|
|||
|
|||
(15C) Fibonacci Numbers
This program calculates the nth Fibonacci number. Store n in memory register 0 before running the program.
Formula: ( (1 + √5)^n – (1 - √5)^n ) / (2^n * √5) Caution: Due to internal calculator calculation, you may not get an integer answer. You might have to round the answer manually. From Joe Horn, with thanks and appreciation for letting me post his comment: "Hi, Eddie! I just keyed up your HP-15C program for Fibonacci numbers, and noticed that it gets wrong answers due to round-off errors much of the time. For example, with an input of 5, it should output 5, but it outputs 4.9999999998. Even rounding to the nearest integer doesn't fix the problem for inputs of 40 through 49. The only way to get the right answers for all inputs is with a loop (the usual method)." - Joe Horn I would recommend running this program when n< 40. Code:
Example: R0 = n = 16, Output: 987 |
|||
« Next Oldest | Next Newest »
|
Messages In This Thread |
(15C) Fibonacci Numbers - Eddie W. Shore - 03-23-2017 03:22 AM
RE: (15C) Fibonacci Numbers (bug with 15C LE?) - Eddie W. Shore - 03-23-2017, 01:32 PM
RE: (15C) Fibonacci Numbers - Albert Chan - 08-07-2023, 10:09 PM
RE: (15C) Fibonacci Numbers - Werner - 08-08-2023, 11:05 AM
RE: (15C) Fibonacci Numbers - Albert Chan - 08-08-2023, 11:44 AM
RE: (15C) Fibonacci Numbers - Thomas Klemm - 08-06-2023, 11:06 AM
RE: (15C) Fibonacci Numbers - Joe Horn - 08-06-2023, 04:49 PM
RE: (15C) Fibonacci Numbers - Thomas Klemm - 08-06-2023, 03:16 PM
RE: (15C) Fibonacci Numbers - Thomas Klemm - 08-07-2023, 10:49 PM
RE: (15C) Fibonacci Numbers - Werner - 08-08-2023, 12:06 PM
|
User(s) browsing this thread: 6 Guest(s)