A295897 Numbers in whose binary expansion there are no 1-runs of odd length followed by a 0 to their right.
0, 1, 3, 6, 7, 12, 13, 15, 24, 25, 27, 30, 31, 48, 49, 51, 54, 55, 60, 61, 63, 96, 97, 99, 102, 103, 108, 109, 111, 120, 121, 123, 126, 127, 192, 193, 195, 198, 199, 204, 205, 207, 216, 217, 219, 222, 223, 240, 241, 243, 246, 247, 252, 253, 255, 384, 385, 387, 390, 391, 396, 397, 399, 408, 409, 411, 414, 415, 432
Offset: 1
Links
Crossrefs
Programs
-
Python
[x ^ (x>>1) for x in range(0,2048) if (x & (x<<1) == 0)] # Frédéric Nouvier, Aug 14 2020
-
Python
def A295897(n): tlist, s = [1,2], 0 while tlist[-1]+tlist[-2] <= n: tlist.append(tlist[-1]+tlist[-2]) for d in tlist[::-1]: s <<= 1 if d <= n: s += 1 n -= d return s>>1^s # Chai Wah Wu, Apr 25 2025
-
Rust
fn main() { for i in (0..2048) // Filter to get A003714 .filter(|n| n & (n << 1) == 0) // Map to produce A295897 .map(|n| n ^ (n >> 1)) { println!("{}", i); } } // Frédéric Nouvier, Aug 14 2020
Comments