A333860 The maximum Hamming (binary) weight of the elements of the Collatz orbit of n, or -1 if 1 is never reached.
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, 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, 3, 4, 8, 3, 8, 3, 4, 4, 4, 5, 6, 2, 5, 8, 8, 3, 4, 4, 5
Offset: 1
Examples
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.
Links
- Markus Sigg, Table of n, a(n) for n = 1..10000
Programs
-
Mathematica
a[n_] := Max[DigitCount[#, 2, 1] & /@ NestWhileList[If[OddQ[#], 3*# + 1, #/2] &, n, # > 1 &]]; Array[a, 100] (* Amiram Eldar, Jul 29 2023 *)
-
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; }
Formula
Extensions
Escape clause added to the definition by Antti Karttunen, Apr 10 2022