OFFSET
1,2
COMMENTS
Numbers that have ones in all even bit positions, counted from least significant bit as position 0. - Ralf Stephan, Nov 01 2003
LINKS
Vincenzo Librandi, Table of n, a(n) for n = 1..1000
FORMULA
a(2n) = 4a(n) + 1, a(2n+1) = 4a(n) + 3. - Ralf Stephan, Nov 01 2003
EXAMPLE
Sequence in binary: 1 11 101 111 1101 1111 10101 10111 11101 11111 ...
MATHEMATICA
Flatten[Table[FromDigits[#, 4]&/@Tuples[{1, 3}, n], {n, 5}]] (* Vincenzo Librandi, May 31 2012 *)
PROG
(Magma) [n: n in [1..1000] | Set(IntegerToSequence(n, 4)) subset {1, 3}]; // Vincenzo Librandi, May 31 2012
(C) uint32_t a_next(uint32_t a_n) { return (a_n + 1) | (a_n & 0x55555555); } /* Falk Hüffner, Jan 24 2022 */
(Python)
def A032911(n): return (int(bin(m:=n+1)[3:], 4)<<1) + ((1<<(m.bit_length()-1<<1))-1)//3 # Chai Wah Wu, Oct 13 2023
CROSSREFS
KEYWORD
nonn,base,easy
AUTHOR
STATUS
approved