>>> def f(n):
... p = -1
... while n > 0:
... d = n & 0x1
... if d == p:
... return False
... p = d
... n >>= 1
... return True
...
>>> for i in range(65):
... i, f(i), bin(i)
...
(0, True, '0b0')
(1, True, '0b1')
(2, True, '0b10')
(3, False, '0b11')
(4, False, '0b100')
(5, True, '0b101')
(6, False, '0b110')
(7, False, '0b111')
(8, False, '0b1000')
(9, False, '0b1001')
(10, True, '0b1010')
(11, False, '0b1011')
(12, False, '0b1100')
(13, False, '0b1101')
(14, False, '0b1110')
(15, False, '0b1111')
(16, False, '0b10000')
(17, False, '0b10001')
(18, False, '0b10010')
(19, False, '0b10011')
(20, False, '0b10100')
(21, True, '0b10101')
(22, False, '0b10110')
(23, False, '0b10111')
(24, False, '0b11000')
(25, False, '0b11001')
(26, False, '0b11010')
(27, False, '0b11011')
(28, False, '0b11100')
(29, False, '0b11101')
(30, False, '0b11110')
(31, False, '0b11111')
(32, False, '0b100000')
(33, False, '0b100001')
(34, False, '0b100010')
(35, False, '0b100011')
(36, False, '0b100100')
(37, False, '0b100101')
(38, False, '0b100110')
(39, False, '0b100111')
(40, False, '0b101000')
(41, False, '0b101001')
(42, True, '0b101010')
(43, False, '0b101011')
(44, False, '0b101100')
(45, False, '0b101101')
(46, False, '0b101110')
(47, False, '0b101111')
(48, False, '0b110000')
(49, False, '0b110001')
(50, False, '0b110010')
(51, False, '0b110011')
(52, False, '0b110100')
(53, False, '0b110101')
(54, False, '0b110110')
(55, False, '0b110111')
(56, False, '0b111000')
(57, False, '0b111001')
(58, False, '0b111010')
(59, False, '0b111011')
(60, False, '0b111100')
(61, False, '0b111101')
(62, False, '0b111110')
(63, False, '0b111111')
(64, False, '0b1000000')
>>>