I am trying to solve this problem: Problem 44481. How many Fibonacci numbers? This is what I've done
function y = fib_count(x)
a=unique(x);
a(mod(sqrt(5*a.^2+4),1)~=0&mod(sqrt(5*a.^2-4),1)~=0)=[];
y=length(a);
end
The problem is when there are large numbers, like 8944394323791465
, they will all be Fibonacci numbers, no matter what.
I tried this: mod(10^20+1,2)
and it returns 0
.
Have you dealt with this before?