login
A129972
a(n) = 2*floor(log_2(n)) + 1.
3
1, 3, 3, 5, 5, 5, 5, 7, 7, 7, 7, 7, 7, 7, 7, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13
OFFSET
1,2
COMMENTS
The number of bits needed to write n using Elias gamma coding. - Charles R Greathouse IV, Mar 21 2012
Consists of the n-th odd number (A005408(n) = 2n+1) repeated 2^(n-1) times (since a(n) = a(n-1) except when a(n) > a(n-1) which happens for n a power of 2). - Jonathan Vos Post, Jun 17 2007
LINKS
FORMULA
a(n) = Sum_{k=1..n} (-1)^(k-1)*floor(n/k)*mu(k).
PROG
(PARI) a(n)=2*floor(log(n)/log(2))+1
(PARI) a(n)=log(n+.5)\log(2)*2+1 \\ Charles R Greathouse IV, Mar 21 2012
(PARI) a(n)=2*logint(n, 2)+1 \\ Charles R Greathouse IV, Sep 04 2015
CROSSREFS
Cf. A005408.
Cf. A281149 (See the comment section by Charles R Greathouse IV, of this sequence (A129972) ). - Indranil Ghosh, Jan 17 2017
Sequence in context: A265182 A349530 A251549 * A130829 A196386 A035158
KEYWORD
nonn,easy
AUTHOR
Benoit Cloitre, Jun 13 2007
STATUS
approved