[GeeksForGeeks] Check Fibonacci Number

Give a number n, check if it is a fibonacci number.

Solution 1.  Generate a sequence of fibonacci number until we have a fibonacci number that is either greater than or equal to n.

If greater than, return false; If equal to, return true.

Solution 2. 

A number is Fibonacci if and only if one or both of (5*n^2 + 4) or (5*n^2 – 4) is a perfect square (Source: Wiki). 

原文地址:https://www.cnblogs.com/lz87/p/7266434.html