A271479 Number of steps for the trajectory of n under the map k -> A271478(k) to reach 1.
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
Keywords
Links
- N. J. A. Sloane, Table of n, a(n) for n = 1..10000
- Christian Krause, LODA program for A271479
Programs
-
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 *)
-
PARI
a(n) = if(n--, 3*(logint(n,2)+1) - 2*hammingweight(n), 0); \\ Kevin Ryde, Mar 21 2021
Formula
a(1) = 0; a(2*n) = a(n)+1; a(2*n+1) = a(n+1)+3. - Christian Krause, Mar 19 2021
Comments