|
| |
|
|
A056792
|
|
(Weight of binary expansion of n) + (length of binary expansion of n) - 1
|
|
11
| |
|
|
0, 1, 2, 3, 3, 4, 4, 5, 4, 5, 5, 6, 5, 6, 6, 7, 5, 6, 6, 7, 6, 7, 7, 8, 6, 7, 7, 8, 7, 8, 8, 9, 6, 7, 7, 8, 7, 8, 8, 9, 7, 8, 8, 9, 8, 9, 9, 10, 7, 8, 8, 9, 8, 9, 9, 10, 8, 9, 9, 10, 9, 10, 10, 11, 7, 8, 8, 9, 8, 9, 9, 10, 8, 9, 9, 10, 9, 10, 10, 11, 8, 9, 9, 10, 9, 10, 10, 11, 9, 10, 10, 11, 10, 11
(list; graph; refs; listen; history; internal format)
|
|
|
|
OFFSET
| 0,3
|
|
|
COMMENTS
| Minimal number of steps to get from 0 to n by (a) adding 1 or (b) multiplying by 2.
A stopping problem: begin with n and at each stage if even divide by 2 or if odd subtract 1. That is, iterate A029578 while nonzero.
|
|
|
LINKS
| Hugo Pfoertner, Addition chains
|
|
|
FORMULA
| a(0) = 0, a(2n+1) = a(2n) + 1 and a(2n) = a(n) + 1.
n>0 a(n)=n-valuation(A000254(n), 2) - Benoit Cloitre (benoit7848c(AT)orange.fr), Mar 09 2004
|
|
|
EXAMPLE
| 12 = 1100 in binary, so a(12)=2+4-1=5.
|
|
|
MATHEMATICA
| f[ n_Integer ] := (c = 0; k = n; While[ k != 0, If[ EvenQ[ k ], k /= 2, k-- ]; c++ ]; c); Table[ f[ n ], {n, 0, 100} ]
|
|
|
PROG
| (PARI) a(n)=if(n<1, 0, n-valuation(n!*sum(i=1, n, 1/i), 2))
(PARI) a(n)=if(n<1, 0, 1+a(if(n%2, n-1, n/2)))
|
|
|
CROSSREFS
| Equals A056791 - 1. The least inverse (indices of record values) of A056792 is A052955 prepended with 0. See also A014701, A115954, A056796, A056817.
Sequence in context: A060607 A061339 A073933 * A130500 A072073 A061716
Adjacent sequences: A056789 A056790 A056791 * A056793 A056794 A056795
|
|
|
KEYWORD
| nonn,easy
|
|
|
AUTHOR
| N. J. A. Sloane (njas(AT)research.att.com), Sep 01 2000
|
|
|
EXTENSIONS
| More terms from James A. Sellers (sellersj(AT)math.psu.edu), Sep 06 2000 and from David W. Wilson (davidwwilson(AT)comcast.net), Sep 07, 2000
|
| |
|
|