cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

A333860 The maximum Hamming (binary) weight of the elements of the Collatz orbit of n, or -1 if 1 is never reached.

Original entry on oeis.org

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

Views

Author

Markus Sigg, Apr 08 2020

Keywords

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.
		

Crossrefs

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

a(n) = max(A000120(n), A352895(n)) = max(A000120(n), a(A006370(n))). - Antti Karttunen, Apr 10 2022

Extensions

Escape clause added to the definition by Antti Karttunen, Apr 10 2022