I wrote the following program to check whether a number lies in the series of fibonacci number(s),
A number "x" is said to be in the series if it satisfies one or both of the following
conditions :
1) 5x^2 - 4 is a perfect square
2) 5x^2 +4 is a perfect square
tons of cases but when the output will be same it will not differential between a long long int and a long double ….try simple numbers like 7 or 8 or any number which is like within 1-100000…...
In the list you posted in your first post, only three are fibonacci numbers anyway:
21
196418
5702887
So your list is mixed between fib and non-fib. Is your program reporting incorrectly for all the values you listed?
this expands the range a little:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
void testfib (longdouble fibtry)
{
longlongint ptesttint, mtestint;
longdouble ptestdbl,mtestdbl;
ptestdbl = sqrt(5 * pow(fibtry,2) + 4);
mtestdbl = sqrt(5 * pow(fibtry,2) - 4);
// convert to long long int
ptestint = ptestdbl;
mtestint = mtestdbl;
if ( ptestdbl - ptestint > 0 && mtestdbl - mtestint > 0)
// not fib
else
// fib
}
this got me to element 72 with accurate results; after 72, the test wasn't accurate, because fibtry, fibtry + 1, fibtry -1 all were reported as fib numbers.