Fibbinary Numbers ( No consecutive 1 s in binary ) | Java implementation to check whether a number is fibbinary or not ; function to check whether a number is fibbinary or not ; if the number does not contain adjacent ones then ( n & ( n >> 1 ) ) operation results to 0 ; not a fibbinary number ; Driver program to test above
class GFG { static boolean isFibbinaryNum ( int n ) { if ( ( n & ( n >> 1 ) ) == 0 ) return true ; return false ; } public static void main ( String [ ] args ) { int n = 10 ; if ( isFibbinaryNum ( n ) == true ) System . out . println ( " Yes " ) ; else System . out . println ( " No " ) ; } }