login
A271479
Number of steps for the trajectory of n under the map k -> A271478(k) to reach 1.
3
0, 1, 4, 2, 7, 5, 5, 3, 10, 8, 8, 6, 8, 6, 6, 4, 13, 11, 11, 9, 11, 9, 9, 7, 11, 9, 9, 7, 9, 7, 7, 5, 16, 14, 14, 12, 14, 12, 12, 10, 14, 12, 12, 10, 12, 10, 10, 8, 14, 12, 12, 10, 12, 10, 10, 8, 12, 10, 10, 8, 10, 8, 8, 6, 19, 17, 17, 15, 17, 15, 15, 13, 17, 15, 15, 13, 15, 13
OFFSET
1,3
COMMENTS
Arises in studying A266569.
Records are 0, 1, 4, 7, 10, 13, 16, 19, 22, 25, 28, 31, 34, 37, 40, ... and occur at positions 1, 2, 3, 5, 9, 17, 33, 65, 129, 257, 513, 1025, 2049, 4097, 8193, ...
LINKS
Christian Krause, LODA program for A271479
FORMULA
a(1) = 0; a(2*n) = a(n)+1; a(2*n+1) = a(n+1)+3. - Christian Krause, Mar 19 2021
a(n) = A000120(n-1) + 3*A023416(n-1), for n>=2. - Kevin Ryde, Mar 21 2021
MAPLE
f:=n->if n mod 2 = 0 then n/2 else 2*n+2; fi; # A271478
a:=[]; B:=1000;
for n from 1 to 100 do
ct:=0; s:=n;
for k from 1 to B while s>1 do
s:=f(s); ct:=ct+1; od:
if ct=B then lprint("error, need to increase limit B"); break; fi;
a:=[op(a), ct]; od:
a;
MATHEMATICA
Table[Length[NestWhileList[If[EvenQ[#], #/2, 2#+2]&, n, #!=1&]]-1, {n, 80}] (* Harvey P. Dale, May 02 2017 *)
PROG
(PARI) a(n) = if(n--, 3*(logint(n, 2)+1) - 2*hammingweight(n), 0); \\ Kevin Ryde, Mar 21 2021
CROSSREFS
KEYWORD
nonn
AUTHOR
N. J. A. Sloane, Apr 10 2016
STATUS
approved