Check if a number is Full Fibonacci or not | Python3 program to check if a given number is a Full Fibonacci Number or not ; A utility function that returns true if x is perfect square ; Returns true if N is a Fibonacci Number and false otherwise ; N is Fibonacci if one of 5 * N ^ 2 + 4 or 5 * N ^ 2 - 4 or both is a perferct square ; Function to check digits ; Check if all digits are fibonacci or not ; Extract digit ; Check if the current digit is not fibonacci ; Function to check and return if N is a Full Fibonacci number or not ; Driver Code
from math import * NEW_LINE def isPerfectSquare ( x ) : NEW_LINE INDENT s = sqrt ( x ) NEW_LINE return ( s * s == x ) NEW_LINE DEDENT def isFibonacci ( n ) : NEW_LINE INDENT return ( isPerfectSquare ( 5 * n * n + 4 ) or isPerfectSquare ( 5 * n * n - 4 ) ) NEW_LINE DEDENT def checkDigits ( n ) : NEW_LINE INDENT while ( n ) : NEW_LINE INDENT dig = n % 10 NEW_LINE if ( dig == 4 and dig == 6 and dig == 7 and dig == 9 ) : NEW_LINE INDENT return False NEW_LINE DEDENT n /= 10 NEW_LINE DEDENT return True NEW_LINE DEDENT def isFullfibonacci ( n ) : NEW_LINE INDENT return ( checkDigits ( n ) and isFibonacci ( n ) ) NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT n = 13 NEW_LINE if ( isFullfibonacci ( n ) ) : NEW_LINE INDENT print ( " Yes " ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( " No " ) NEW_LINE DEDENT DEDENT