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!)
A263716 Irregular triangle read by rows: numbers in the Collatz conjecture in the order of their first appearance. 4

%I #41 Dec 15 2022 05:23:45

%S 1,2,3,10,5,16,8,4,6,7,22,11,34,17,52,26,13,40,20,9,28,14,12,15,46,23,

%T 70,35,106,53,160,80,18,19,58,29,88,44,21,64,32,24,25,76,38,27,82,41,

%U 124,62,31,94,47,142,71,214,107,322,161,484,242,121,364,182

%N Irregular triangle read by rows: numbers in the Collatz conjecture in the order of their first appearance.

%C This is the irregular triangle read by rows giving trajectory of n in the Collatz problem, flattened and with all the repeated terms deleted.

%C This sequence goes to infinity as n gets larger. On the Collatz conjecture this sequence is a permutation of the positive integers. [Corrected by _Charles R Greathouse IV_, Jul 29 2016]

%H Daniel Suteu, <a href="/A263716/b263716.txt">Table of n, a(n) for n = 0..19999</a>

%H <a href="/index/3#3x1">Index entries for sequences related to 3x+1 (or Collatz) problem</a>

%F row(n) = {

%F if seen[n]: stop

%F else: write(n) and do:

%F | n is one: stop

%F | n is odd: n <- 3*n+1

%F | n is even: n <- n/2

%F }

%e Triangle begins:

%e 1;

%e 2;

%e 3, 10, 5, 16, 8, 4;

%e ...

%e The Collatz trajectories for the first five positive integers are {1}, {2, 1}, {3, 10, 5, 16, 8, 4, 2, 1}, {4, 2, 1}, {5, 16, 8, 4, 2, 1}.

%e From {2, 1} we delete 1 because it has already occurred. From {3, 10, 5, ..., 4, 2, 1} we delete {2, 1} because both numbers have already occurred. We completely get rid of {4, 2, 1} because it has already occurred as the tail end of {3, 10, 5, ...}, and we also completely get rid of {5, 16, 8, ...} for the same reason.

%e This leaves us with {1}, {2}, {3, 10, 5, 16, 8, 4}, thus accounting for the first eight terms of this sequence.

%t collatz[n_] := NestWhileList[If[EvenQ[#], #/2, 3 # + 1] &, n, # > 1 &]; DeleteDuplicates[Flatten[Table[collatz[n], {n, 20}]]] (* _Alonso del Arte_, Oct 24 2015 *)

%o (Sidef)

%o func collatz(n) is cached { # automatically memoized function

%o say n; # prints the first unseen numbers

%o n.is_one ? 0

%o : (n.is_even ? collatz(n/2)

%o : collatz(3*n + 1));

%o }

%o range(1, Math.inf).each { |i| collatz(i) }

%Y Cf. A006577, A070165, A222118 (row lengths).

%Y Cf. A347265 (essentially the same).

%K nonn,tabf,easy,nice

%O 0,2

%A _Daniel Suteu_, Oct 24 2015

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.)