• + 0 comments

    This is my code for the problem isFibo . We are supposed to create a function which would detect if a number is a fibonacci number or not and returns IsFibo if it is one and IsNotFibo otherwise. But for n >= 28657 which is a fibonacci number this test fails, as p and q are then coming negative. Can someone please say what is wrong with my code?

    string isFibo(long n) { if(n==0) return "IsFibo"; long long p=5*n*n-4; long long q=5*n*n+4; cout<