OFFSET
0,3
COMMENTS
These are 0 and the words where the bit count is 2^i where i is the index of the lowest set bit.
LINKS
Paolo Xausa, Table of n, a(n) for n = 0..10000
Joerg Arndt, Fxtbook, section 1.26.4 "The sequence of fixed points", p.73-74
EXAMPLE
Zero is a fixed point: 0: ...........
The next few in decimal and binary form (dots for zeros), lowest (rightmost) bit has index zero are:
1: ............1
6: ..........11.
10: ........1.1.
18: .......1..1.
34: ......1...1.
60: ......1111..
66: .....1....1.
92: .....1.111..
108: ....11.11..
116: ....111.1..
130: ...1.....1.
MATHEMATICA
Join[{0}, Select[Range[10^4], DigitCount[#, 2, 1]==2^IntegerExponent[#, 2]&]] (* Paolo Xausa, Nov 13 2023 *)
PROG
(C++)
/* Generate the binary words lex order:
start with zero and get successive elements via */
inline ulong prev_lexrev(ulong x)
/* Return previous word in (reversed) lex order. */
{
ulong x0 = x & -x;
if ( x & (x0<<1) ) x ^= x0;
else { x0 ^= (x0<<1); x ^= x0; x |= 1; }
return x;
}
/* To extract the fixed points, select those where
the following function returns a nonzero value: */
ulong is_lexrev_fixed_point(ulong x)
/* Return whether x is a fixed point in the prev_lexrev() - sequence */
{
if ( x & 1 ) { if ( 1==x ) return 1; else return 0; }
else
{
ulong w = bit_count(x);
if ( w != (w & -w) ) return 0;
if ( 0==x ) return 1; return ( (x & -x) & w );
}
}
CROSSREFS
KEYWORD
easy,nonn
AUTHOR
Joerg Arndt, Jan 15 2003
STATUS
approved