%I #19 Dec 07 2019 12:18:28
%S 2,3,10,5,16,8,4,2,4,2,5,16,8,4,2,6,3,10,5,16,8,4,2,7,22,11,34,17,52,
%T 26,13,40,20,10,5,16,8,4,2,8,4,2,9,3,10,5,16,8,4,2,10,5,16,8,4,2,11,
%U 34,17,52,26,13,40,20,10,5,16,8,4,2
%N Irregular triangle read by rows giving the 3p+1 sequence of n.
%C The n-th row of the triangle provides the 3p+1 sequence for n, such that the sequence terminates at the first occurrence of 2. The 3p+1 sequence is a variation of the 3x+1 (Collatz) sequence.
%C The 3p+1 sequence for n >= 2 is defined as follows: b(0) = n; b(n+1) = 3 * b(n) + 1 if b(n) is prime; otherwise, b(n+1) = b(n) divided by the smallest prime factor of b(n).
%C It seems that all 3p+1 sequences reach 2. This has been verified for n up to 5*10^8. Once a 3p+1 sequence reaches 2, it repeats the following cycle: 2, 7, 22, 11, 34, 17, 52, 26, 13, 40, 20, 10, 5, 16, 8, 4, 2, ...
%H Jack Brennen, Felice Russo, <a href="http://www.primepuzzles.net/puzzles/puzz_073.htm">A Collatz-like sequence.</a>
%e The irregular array a(n,k) starts:
%e n\k 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
%e 2: 2
%e 3: 3 10 5 16 8 4 2
%e 4: 4 2
%e 5: 5 16 8 4 2
%e 6: 6 3 10 5 16 8 4 2
%e 7: 7 22 11 34 17 52 26 13 40 20 10 5 16 8 4 2
%e 8: 8 4 2
%e 9: 9 3 10 5 16 8 4 2
%e 10: 5 16 8 4 2
%e 11: 11 34 17 52 26 13 40 20 10 5 16 8 4 2
%o (PARI) row(n) = {print1 (n, ", "); while (n!=2, nn = if (isprime(n), 3*n+1, n/factor(n)[1,1]); print1(nn, ", "); n=nn);} \\ _Michel Marcus_, Jan 02 2016
%o (Python)
%o from sympy import isprime, primefactors
%o def a(n):
%o if n==2: return [2]
%o l=[n, ]
%o while True:
%o if isprime(n): n = 3*n + 1
%o else: n/=min(primefactors(n))
%o l+=[n, ]
%o if n==2: break
%o return l
%o for n in range(2, 21): print a(n) # _Indranil Ghosh_, Apr 22 2017
%Y Cf. A266551 (image of n under the 3p+1 map).
%Y Cf. A175871 (the repeating cycle starting at 2).
%Y Cf. A070165 (irregular triangle read by rows giving trajectory of n in Collatz problem).
%K nonn,tabf
%O 2,1
%A _Robert C. Lyons_, Dec 31 2015