VOOZH about

URL: https://www.geeksforgeeks.org/dsa/check-if-a-number-is-full-fibonacci-or-not/

⇱ Check if a number is Full Fibonacci or not - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Check if a number is Full Fibonacci or not

Last Updated : 12 Jul, 2025

Given a number N, the task is to check if the given number and all its digits are Fibonacci. If so, then the given number is a Full Fibonacci Number, else not.
Examples: 

Input: 13 
Output: Yes 
Explanation: 13 and its digits 1 and 3 are all Fibonacci numbers


Input: 34 
Output: No 
Explanation: 4 is not a Fibonacci number. 

Approach: 
First check if all digits of N are Fibonacci or not. If so, similarly check if N is Fibonacci or not by the principle that a number is Fibonacci if and only if one or both of (5*N2 + 4) or (5*N2 – 4) is a perfect square.
Below code is the implementation of the above approach: 


Output: 
Yes

 

Time Complexity: O(logn) 
Auxiliary Space: O(1)

Comment
Article Tags: