You would need a representation with at least 67 bits to hold the result of 5*n*n when n is 4522240457. I would guess the unsigned long long data type on the target system has fewer bits.
The whole idea of the site your visiting is that you find a way to get the correct output.. So, put on your thinking cap and quit blindly googling/copying code.
How many fibonacci numbers do you suppose there are less than 1010?
The whole idea of the site your visiting is that you find a way to get the correct output.. So, put on your thinking cap and quit blindly googling/copying code.
The code that you see above is written by me; I haven't copied it from google.
How many fibonacci numbers do you suppose there are less than 1010?
If we take the first two numbers as 0 and 1 then the answer would be 50. The last being 7778742049
Am I correct?
Still it's showing the wrong output.
I wrote a code to generate all the Fibonacci numbers from 0 to 50
And I found that 4522240457 is not even a Fibonacci number.
My question is why does the hackerrank's output shows 4522240457 as a Fibonacci number?
I feel like a complete idiot now. All I needed was to realize that the lines in input and output are different. Also I increased my size of the array to accommodate larger inputs. After doing this my code passed all test cases.