Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
A081743
a(1)=1 then a(n)=a(n/2^k)+1 if n is even and 2^k is the largest power of 2 dividing n, a(n)=a(n-1) otherwise.
1
1, 2, 2, 2, 2, 3, 3, 2, 2, 3, 3, 3, 3, 4, 4, 2, 2, 3, 3, 3, 3, 4, 4, 3, 3, 4, 4, 4, 4, 5, 5, 2, 2, 3, 3, 3, 3, 4, 4, 3, 3, 4, 4, 4, 4, 5, 5, 3, 3, 4, 4, 4, 4, 5, 5, 4, 4, 5, 5, 5, 5, 6, 6, 2, 2, 3, 3, 3, 3, 4, 4, 3, 3, 4, 4, 4, 4, 5, 5, 3, 3, 4, 4, 4, 4, 5, 5, 4, 4, 5, 5, 5, 5, 6, 6, 3, 3, 4, 4, 4, 4, 5, 5, 4, 4
OFFSET
1,2
LINKS
FORMULA
a(n) = A000120(n) + A059841(n). - Robert Israel, Sep 09 2020
MAPLE
a:= proc(n) option remember;
if n::even then 1+procname(n/2^padic:-ordp(n, 2)) else procname(n-1) fi
end proc:
a(1):= 1:
map(a, [$1..200]); # Robert Israel, Sep 09 2020
MATHEMATICA
Nest[Append[#1, If[EvenQ@ #2, 1 + #1[[#2/2^IntegerExponent[#2, 2]]], #1[[-1]] ]] & @@ {#, Length@ # + 1} &, {1}, 104] (* Michael De Vlieger, Sep 09 2020 *)
PROG
(PARI) a(n)=if(n<2, 1, if(n%2, a(n-1), a(n/2^valuation(n, 2))+1))
CROSSREFS
Sequence in context: A347387 A196046 A152724 * A247069 A367008 A366800
KEYWORD
nonn
AUTHOR
Benoit Cloitre, Apr 07 2003
STATUS
approved