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.

A062052 Numbers with exactly 2 odd integers in their Collatz (or 3x+1) trajectory.

This page as a plain text file.
%I A062052 #72 Feb 16 2025 08:32:44
%S A062052 5,10,20,21,40,42,80,84,85,160,168,170,320,336,340,341,640,672,680,
%T A062052 682,1280,1344,1360,1364,1365,2560,2688,2720,2728,2730,5120,5376,5440,
%U A062052 5456,5460,5461,10240,10752,10880,10912,10920,10922,20480,21504,21760,21824
%N A062052 Numbers with exactly 2 odd integers in their Collatz (or 3x+1) trajectory.
%C A062052 The Collatz (or 3x+1) function is f(x) = x/2 if x is even, 3x+1 if x is odd.
%C A062052 The Collatz trajectory of n is obtained by applying f repeatedly to n until 1 is reached.
%C A062052 The sequence consists of terms of A002450 and their 2^k multiples. The first odd integer in the trajectory is one of the terms of A002450 and the second odd one is the terminal 1. - _Antti Karttunen_, Feb 21 2006
%C A062052 This sequence looks to appear first in the literature on page 1285 in R. E. Crandall.
%H A062052 Reinhard Zumkeller and T. D. Noe, <a href="/A062052/b062052.txt">Table of n, a(n) for n = 1..1000</a> (first 100 terms from Reinhard Zumkeller)
%H A062052 R. E. Crandall, <a href="http://dx.doi.org/10.1090/S0025-5718-1978-0480321-3">On the 3x+1 problem</a>, Math. Comp., 32 (1978) 1281-1292.
%H A062052 J. Shallit and D. Wilson, <a href="http://www.cs.uwaterloo.ca/~shallit/Papers/wilson.ps">The "3x+1" Problem and Finite Automata</a>, Bulletin of the EATCS #46 (1992) pp. 182-185.
%H A062052 Eric Weisstein's World of Mathematics, <a href="https://mathworld.wolfram.com/CollatzProblem.html">Collatz Problem</a>
%H A062052 Wikipedia, <a href="http://en.wikipedia.org/wiki/Collatz_conjecture">Collatz conjecture</a>
%H A062052 <a href="/index/3#3x1">Index entries for sequences related to 3x+1 (or Collatz) problem</a>
%H A062052 <a href="/index/Ar#2-automatic">Index entries for 2-automatic sequences</a>.
%F A062052 A078719(a(n)) = 2; A006667(a(n)) = 1.
%F A062052 a(n) = 2^x * (4^y - 1)/3 where x = A122196(n) - 1 and y = A122197(n) + 1. - _Alan Michael Gómez Calderón_, Jan 16 2025 after _Antti Karttunen_
%e A062052 The Collatz trajectory of 5 is (5,16,8,4,2,1), which contains 2 odd integers.
%t A062052 Collatz[n_] := NestWhileList[If[EvenQ[#], #/2, 3 # + 1] &, n, # > 1 &]; countOdd[lst_] := Length[Select[lst, OddQ]]; Select[Range[22000], countOdd[Collatz[#]] == 2 &] (* _T. D. Noe_, Dec 03 2012 *)
%o A062052 (PARI) for(n=2,100000,s=n; t=0; while(s!=1,if(s%2==0,s=s/2,s=3*s+1; t++); if(s*t==1,print1(n,","); ); ))
%o A062052 (Haskell)
%o A062052 import Data.List (elemIndices)
%o A062052 a062052 n = a062052_list !! (n-1)
%o A062052 a062052_list = map (+ 1) $ elemIndices 2 a078719_list
%o A062052 -- _Reinhard Zumkeller_, Oct 08 2011
%o A062052 (Python)
%o A062052 def a(n):
%o A062052     l=[n, ]
%o A062052     while True:
%o A062052         if n%2==0: n//=2
%o A062052         else: n = 3*n + 1
%o A062052         if n not in l:
%o A062052             l.append(n)
%o A062052             if n<2: break
%o A062052         else: break
%o A062052     return len([i for i in l if i % 2])
%o A062052 print([n for n in range(1, 22001) if a(n)==2]) # _Indranil Ghosh_, Apr 14 2017
%Y A062052 Cf. A062053, A062054, A062055, A062056, A062057, A062058, A062059, A062060, A122196, A122197.
%Y A062052 Is this a subset of A115774?
%Y A062052 Column k=2 of A354236.
%K A062052 nonn
%O A062052 1,1
%A A062052 _David W. Wilson_