OFFSET
0,2
COMMENTS
The Collatz function is an integer-valued function given by n/2 if n is even and 3n+1 if n is odd. We build a Collatz sequence by beginning with a natural number and iterating the function indefinitely. It is conjectured that all such sequences terminate at 1.
In this triangle, row n is made up of the odd terms of the Collatz sequence beginning with 2n+1. Therefore, it is conjectured that this sequence is well-defined, i.e., that all rows terminate at 1.
The last index k in row n gives the number of iterations required for the Collatz sequence to terminate if even terms are omitted.
T(n,k)/T(n,k+1) is of form: ceiling(T(n,k)*3/2^j) for some j>=1. Therefore, the coefficients in each row may be read as a series of iterated ceilings, where j may vary. For example, row 3 has initial term 7, which is followed by ceiling(7*3/2), ceiling(ceiling(7*3/2)*3/2), ceiling(ceiling(ceiling(7*3/2)*3/2)*3/4), ceiling(ceiling(ceiling(ceiling(7*3/2)*3/2)*3/4)*3/8), ceiling(ceiling(ceiling(ceiling(ceiling(7*3/2)*3/2)*3/4)*3/8)*3/16).
The length of row n is A258145(n) (set to 0 if 1 is not reached after a finite number of steps). - Wolfdieter Lang, Aug 11 2021
LINKS
Eric Weisstein's World of Mathematics, Collatz Problem
Wikipedia, Collatz conjecture
EXAMPLE
Triangle starts T(0,0):
n\k 0 1 2 3 4 5 6 7 8 9 10 ...
0: 1
1: 3 5 1
2: 5 1
3: 7 11 17 13 5 1
4: 9 7 11 17 13 5 1
5: 11 17 13 5 1
6: 13 5 1
7: 15 23 35 53 5 1
8: 17 13 5 1
9: 19 29 11 17 13 5 1
10: 21 1
11: 23 35 53 5 1
12: 25 19 29 11 17 13 5 1
...
n=13 starts with 27 and takes 41 steps: (27), 41, 31, 47, 71, 107,... 53, 5, 1, (see A372443).
Row 8 is [17, 13, 5, 1] because it is the subsequence of odd terms for the Collatz sequence starting with 17: [17, 52, 26, 13, 40, 20, 10, 5, 16, 8, 4, 2, 1].
MATHEMATICA
f[n_] := NestWhileList[(3*# + 1)/2^IntegerExponent[3*# + 1, 2] &, 2*n + 1, # > 1 &]; Grid[Table[f[n], {n, 0, 12}]] (* L. Edson Jeffery, Apr 25 2015 *)
PROG
(Sage)
def Collatz(n):
A = [n]
b = A[-1]
while b != 1:
if is_even(b):
A.append(b//2)
else:
A.append(3*b+1)
return A
[y for sublist in [[x for x in Collatz(2*n+1) if is_odd(x)] for n in [0..15]] for y in sublist] # Tom Edgar, Apr 04 2015
(PARI) row(n) = {my(oddn = 2*n+1, vl = List(oddn), x); while (oddn != 1, x = 3*oddn+1; oddn = x >> valuation(x, 2); listput(vl, oddn)); Vec(vl); }
tabf(nn) = {for (n=0, nn, my(rown = row(n)); for (k=1, #rown, print1(rown[k], ", ")); print; ); } \\ Michel Marcus, Oct 04 2019
CROSSREFS
KEYWORD
nonn,tabf
AUTHOR
Bob Selcoe, Apr 03 2015
STATUS
approved