+ 8

[Challenge 4] Program to check given number is fibbinary or not.?

Integers whose binary representation contains no consecutive ones is a fibbinary number. Write a program to check given number is fibbinary or not in complexity O(1). Input : 9 Output : Fibbinary Input : 6 Output : No https://code.sololearn.com/cmZ7VoSt08jm/?ref=app

18th Feb 2018, 12:35 PM
Ajay Gaikwad
Ajay Gaikwad - avatar
5 Respostas
+ 7
https://code.sololearn.com/chr32j913VDV/?ref=app
19th Feb 2018, 6:47 AM
Sachin
Sachin - avatar
+ 2
print(["","not "][not (x&(x>>1))]+"fibbinary") because x&(x>>1) equals zero if and only if x includes no condecutives ones
18th Feb 2018, 3:53 PM
VcC
VcC - avatar
+ 1
Nice challenge!
18th Feb 2018, 9:56 PM
Nitzan
Nitzan - avatar
19th Feb 2018, 7:27 AM
m_sudhu
m_sudhu - avatar