%I #37 Jul 29 2023 03:18:28
%S 1,1,2,1,2,2,3,1,3,2,3,2,3,3,4,1,3,3,4,2,3,3,4,2,4,3,8,3,4,4,8,1,4,3,
%T 4,3,3,4,5,2,8,3,4,3,4,4,8,2,3,4,4,3,4,8,8,3,4,4,5,4,5,8,8,1,3,4,4,3,
%U 3,4,8,3,8,3,4,4,4,5,6,2,5,8,8,3,4,4,5
%N The maximum Hamming (binary) weight of the elements of the Collatz orbit of n, or -1 if 1 is never reached.
%H Markus Sigg, <a href="/A333860/b333860.txt">Table of n, a(n) for n = 1..10000</a>
%F a(n) = max(A000120(n), A352895(n)) = max(A000120(n), a(A006370(n))). - _Antti Karttunen_, Apr 10 2022
%e 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.
%t a[n_] := Max[DigitCount[#, 2, 1] & /@ NestWhileList[If[OddQ[#], 3*# + 1, #/2] &, n, # > 1 &]]; Array[a, 100] (* _Amiram Eldar_, Jul 29 2023 *)
%o (PARI) a(n) = {
%o my(c = hammingweight(n));
%o while(n>1, n = if(n%2 == 0, n/2, 3*n+1); c = max(c, hammingweight(n)));
%o c;
%o }
%Y Cf. A000120, A006370, A008908, A070165, A333861, A352895, A352897.
%K nonn,easy,base
%O 1,3
%A _Markus Sigg_, Apr 08 2020
%E Escape clause added to the definition by _Antti Karttunen_, Apr 10 2022