I'm trying to solve a Fibonacci problem and am stumbling into rounding issues.
If i = 8670007398507948658051921
then fib1 = 19386725908489880000000000.0
.
My code is below - thanks for any help.
def is_fibonacci?(i)
fib1 = Math.sqrt(5*(i**2)+4)
fib2 = Math.sqrt(5*(i**2)-4)
fib1 == fib1.round || fib2 == fib2.round ? true : false
end