[go: up one dir, main page]

login

Year-end appeal: Please make a donation to the OEIS Foundation to support ongoing development and maintenance of the OEIS. We are now in our 61st year, we have over 378,000 sequences, and we’ve reached 11,000 citations (which often say “discovered thanks to the OEIS”).

Revision History for A243109 (Bold, blue-underlined text is an addition; faded, red-underlined text is a deletion.)

Showing entries 1-10 | older changes
a(n) is the largest number smaller than n and having the same Hamming weight as n, or n if no such number exist.
(history; published version)
#20 by Bruno Berselli at Tue Mar 02 06:02:56 EST 2021
STATUS

reviewed

approved

#19 by Joerg Arndt at Tue Mar 02 04:40:47 EST 2021
STATUS

proposed

reviewed

#18 by Michel Marcus at Tue Mar 02 03:02:09 EST 2021
STATUS

editing

proposed

#17 by Michel Marcus at Tue Mar 02 03:02:05 EST 2021
PROG

(PARI) a(n) = {my(hn = hammingweight(n)); forstep(k=n-1, 1, -1, if (hammingweight(k) == hn, return (k)); ); return (n); } \\ Michel Marcus, Aug 20 2014

STATUS

proposed

editing

#16 by Kevin Ryde at Tue Mar 02 02:57:54 EST 2021
STATUS

editing

proposed

#15 by Kevin Ryde at Tue Mar 02 02:42:59 EST 2021
LINKS

Joerg Arndt, <a href="http://www.jjj.de/fxt/#fxtbook">Matters Computational (The Fxtbook)</a>, section 1.24.1 Co-lexicographic (colex) order, function prev_colex_comb(), and second implementation in FXT library bitcombcolex.h (both 0 when no previous rather than a(n) = n).

#14 by Kevin Ryde at Mon Mar 01 03:53:52 EST 2021
COMMENTS

To calculate a(n), some bits of n are rearranged. The lowest 1-bit which can move down is the 1 of the lowest 10 bit pair in n. This pair becomes 01 in a(n) and any 1's below there move up to immediately below so the decrease is as small as possible. If n has no 10 bit pair (n = 2^k-1) then nothing smaller is possible and a(n) = n. - Kevin Ryde, Mar 01 2021

FORMULA

a(n) = t - 2^(A007814(t) - A007814(n+1) - 1) if t!=0, or a(n) = n if t=0, where t = A129760(n+1) is n with any trailing 1's cleared to 0's and A007814 is the 2-adic valuation. - Kevin Ryde, Mar 01 2021

EXAMPLE

From Kevin Ryde, Mar 01 2021: (Start)

v vv

n = 1475 = binary 10111000011 lowest 10 of n

a(n) = 1464 = binary 10110111000 becomes 01 and

^^^ other 1's below

(End)

PROG

(PARI) a(n) = my(s=n+1, t=bitand(n, s)); if(t==0, n, t - 1<<(valuation(t, 2)-valuation(s, 2)-1)); \\ Kevin Ryde, Mar 01 2021

CROSSREFS

Cf. A057168 (next of same weight), A066884 (array by weight), A241816 (lowest 10->01).

KEYWORD

nonn,base,easy

STATUS

approved

editing

#13 by Michel Marcus at Wed Aug 20 13:17:10 EDT 2014
STATUS

reviewed

approved

#12 by Joerg Arndt at Wed Aug 20 12:52:06 EDT 2014
STATUS

proposed

reviewed

#11 by Philippe Beaudoin at Wed Aug 20 11:36:21 EDT 2014
STATUS

editing

proposed