login
The OEIS is supported by the many generous donors to the OEIS Foundation.

 

Logo
Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A235452 Take the union of all the sequences Collatz(i) for i <= n. The number a(n) is the largest of consecutive numbers beginning with 1. 1

%I #35 Mar 19 2023 14:43:58

%S 1,2,5,5,5,6,8,8,11,11,11,14,14,14,17,17,17,18,20,20,23,23,23,24,26,

%T 26,29,29,29,32,32,32,35,35,35,36,38,38,41,41,41,42,44,44,47,47,47,50,

%U 50,50,53,53,53,54,56,56,59,59,59,62,62,62,65,65,65

%N Take the union of all the sequences Collatz(i) for i <= n. The number a(n) is the largest of consecutive numbers beginning with 1.

%C The Collatz sequence is also called the 3x+1 sequence.

%H Martin Y. Champel, <a href="/A235452/b235452.txt">Table of n, a(n) for n = 1..1000</a>

%e Let the C(n) function compute the Collatz sequence starting at n.

%e For n = 1, C(1) = {1} then term 1 is 1.

%e For n = 2, C(2) = {1,2} then term 2 is 2.

%e For n = 3, C(3) = {3,10,5,16,8,4,2,1} = {1,2,3,4,5,8,10,16} then it contains {1,2,3,4,5} but not {1,2,3,4,5,6} then term 3 is 5.

%e For n = 4, C(4) = C(3) then term 4 is 5.

%e For n = 5, C(5) = C(4) = C(3) then term 5 is 5.

%e For n = 6, C(6) = {1,2,3,4,5,6,8,10,16} then term 6 is 6.

%t Collatz[n_] := NestWhileList[If[EvenQ[#], #/2, 3 # + 1] &, n, # > 1 &]; countConsec[lst_] := Module[{cnt = 0, i = 1}, While[i <= Length[lst] && lst[[i]] == i, cnt++; i++]; cnt]; mx = 0; u = {}; Table[c = Collatz[n]; u = Union[u, c]; mx = Max[mx, countConsec[u]], {n, 65}] (* _T. D. Noe_, Feb 23 2014 *)

%o (Python)

%o def A235452(n=100):

%o a = set([])

%o A235452 = {1: 1}

%o for i in range(2, n):

%o c = i

%o a.add(c)

%o while c != 1:

%o if c % 2 == 1:

%o c = 3 * c + 1

%o a.add(c)

%o c = c / 2

%o a.add(c)

%o k = 1

%o while k in a:

%o k += 1

%o A235452[i] = k - 1

%o return A235452

%o seq_map = A235452()

%o for n in range(1, len(seq_map) + 1):

%o print(seq_map[n], end=", ")

%Y Cf. A061641, A177729.

%K nonn

%O 1,2

%A _Martin Y. Champel_, Jan 10 2014

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recents
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified April 24 04:14 EDT 2024. Contains 371918 sequences. (Running on oeis4.)