• Tutorials
  • DSA
  • Data Science
  • Web Tech
  • Courses
June 28, 2022 |16.7K Views

How to check if a given number is Fibonacci number?

  Share  1 Like
Description
Discussion

A simple way is to generate Fibonacci numbers until the generated number is greater than or equal to ‘n’. Following is an interesting property about Fibonacci numbers that can also be used to check if a given number is Fibonacci or not. 


A number is Fibonacci if and only if one or both of (5*n2 + 4) or (5*n2 – 4) is a perfect square (Source: Wiki). Following is a simple program based on this concept.


How to check if a given number is Fibonacci number : https://www.geeksforgeeks.org/check-number-fibonacci-number/