+ 13

Write a c++ prog. To check whether 55 is in Fibonacci series or not.

17th Aug 2017, 10:24 AM
Nabarup Ghosh
Nabarup Ghosh - avatar
3 Respuestas
+ 2
Really nice question. I think the best way to do this would be to compute every fibonacci number up to N > 55 and check if N == 55 at every iteration. Also (quote: https://stackoverflow.com/questions/2432669/test-if-a-number-is-fibonacci), you can be sure that a number is a fibonacci number if '5N^2-4' is a square number. The problem now is to check if the result is a square number, so still, I think the first option is better. I'm writing a code in c++ for you to understand: https://code.sololearn.com/cSjk9vHUuJ5M
17th Aug 2017, 10:42 AM
prenone
+ 8
thank you very much
17th Aug 2017, 10:38 AM
Nabarup Ghosh
Nabarup Ghosh - avatar
+ 2
No problem, hope the code I wrote helps you ;) https://code.sololearn.com/cSjk9vHUuJ5M
17th Aug 2017, 10:44 AM
prenone