OFFSET
1,3
LINKS
Markus Sigg, Table of n, a(n) for n = 1..10000
FORMULA
EXAMPLE
The Collatz orbit of 3 is 3,10,5,16,8,4,2,1. The Hamming weights are 2,2,2,1,1,1,1,1. The maximum is a(3) = 2.
MATHEMATICA
a[n_] := Max[DigitCount[#, 2, 1] & /@ NestWhileList[If[OddQ[#], 3*# + 1, #/2] &, n, # > 1 &]]; Array[a, 100] (* Amiram Eldar, Jul 29 2023 *)
PROG
(PARI) a(n) = {
my(c = hammingweight(n));
while(n>1, n = if(n%2 == 0, n/2, 3*n+1); c = max(c, hammingweight(n)));
c;
}
CROSSREFS
KEYWORD
nonn,easy,base
AUTHOR
Markus Sigg, Apr 08 2020
EXTENSIONS
Escape clause added to the definition by Antti Karttunen, Apr 10 2022
STATUS
approved