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.

A139391 Next odd term in Collatz trajectory with starting value n.

This page as a plain text file.
%I A139391 #45 Apr 12 2025 16:05:38
%S A139391 1,1,5,1,1,3,11,1,7,5,17,3,5,7,23,1,13,9,29,5,1,11,35,3,19,13,41,7,11,
%T A139391 15,47,1,25,17,53,9,7,19,59,5,31,21,65,11,17,23,71,3,37,25,77,13,5,27,
%U A139391 83,7,43,29,89,15,23,31,95,1,49,33,101,17,13,35,107,9,55,37,113,19,29
%N A139391 Next odd term in Collatz trajectory with starting value n.
%H A139391 Reinhard Zumkeller, <a href="/A139391/b139391.txt">Table of n, a(n) for n = 1..10000</a>
%H A139391 Friedrich L. Bauer, <a href="https://doi.org/10.1007/s00287-008-0231-7">Der (ungerade) Collatz-Baum</a>, Informatik Spektrum 31 (Springer, April 2008).
%H A139391 Eric Weisstein's World of Mathematics, <a href="https://mathworld.wolfram.com/CollatzProblem.html">Collatz Problem</a>.
%H A139391 Wikipedia, <a href="http://en.wikipedia.org/wiki/Collatz_conjecture">Collatz conjecture</a>.
%H A139391 <a href="/index/3#3x1">Index entries for sequences related to 3x+1 (or Collatz) problem</a>.
%F A139391 a(n) = A006370(n) if A006370(n) is odd, otherwise a(A006370(n)).
%F A139391 a(n) = A006370(n) iff n mod 4 = 2;
%F A139391 a(A016825(n)) = A006370(A016825(n));
%F A139391 a(n) = A000265(A006370(n)).
%F A139391 a(A160967(n)) = 1. - _Reinhard Zumkeller_, May 31 2009
%F A139391 For odd n, a(n) = a(2*A350091((n-1)/2)+1). - _Ruud H.G. van Tol_, Dec 17 2021
%F A139391 Sum_{k=1..n} a(k) ~ n^2 / 3. - _Amiram Eldar_, Aug 26 2024
%F A139391 a(n) = A000265(A014682(n)). - _Alan Michael Gómez Calderón_, Apr 10 2025
%t A139391 a[n_]:=Select[NestWhileList[If[EvenQ[#],#/2,3#+1] &,n,#>1 &],OddQ]; Prepend[Table[If[EvenQ[n],a[n][[1]],a[n][[2]]],{n,2,77}],1] (* _Jayanta Basu_, May 27 2013 *)
%o A139391 (Python) # first formula
%o A139391 def A006370(n): return 3*n+1 if n%2 else n//2
%o A139391 def a(n): return x if (x := A006370(n))%2 else a(x)
%o A139391 print([a(n) for n in range(1, 78)]) # _Michael S. Branicky_, Dec 15 2021
%o A139391 (Python) # fourth formula, uses A006370 above
%o A139391 def A000265(n):
%o A139391     while n%2 == 0: n //= 2
%o A139391     return n
%o A139391 def a(n): return A000265(A006370(n))
%o A139391 print([a(n) for n in range(1, 78)]) # _Michael S. Branicky_, Dec 15 2021
%o A139391 (PARI) a(n) = my(x = if(n%2, 3*n+1, n/2)); x/2^valuation(x, 2); \\ _Michel Marcus_, Feb 27 2022
%Y A139391 Cf. A000265, A006370, A014682, A016825, A160967, A350091.
%Y A139391 Cf. A075677 (odd bisection).
%K A139391 nonn,easy
%O A139391 1,3
%A A139391 _Reinhard Zumkeller_, Apr 17 2008