Post Reply 
(12C) Check if given number is Fibonacci number
09-04-2018, 02:00 PM
Post: #2
RE: (12C) Check if given number is Fibonacci number
Nice formula:

If (5 x^2 +/- 4) is perfect square, x is Fibonacci number.

However, there is a weakness if done on the HP-12C.
For x > 44721, the expression overflow 10-digits. Rounding errors kill the algorithm.

So, above code has a safe domain upto 44721 (only 23 Fibonacci numbers in that range)
It might be better to generate the Fibonacci numbers directly, and test the input.
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: (12C) Check if given number is Fibonacci number - Albert Chan - 09-04-2018 02:00 PM



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