%I #19 May 10 2021 02:36:15
%S 7,10,2,16,3,22,4,3,5,34,6,40,7,5,8,52,9,58,10,7,11,70,12,5,13,9,14,
%T 88,15,94,16,11,17,7,18,112,19,13,20,124,21,130,22,15,23,142,24,7,25,
%U 17,26,160,27,11,28,19,29,178,30,184,31,21,32,13,33,202,34,23,35,214,36,220,37,25
%N Image of n under the 3p+1 map, which is a variation of the 3x+1 (Collatz) map.
%C The 3p+1 map is defined for n >= 2 as follows: if n is prime, then map n to 3n+1; otherwise, map n to n divided by the smallest prime divisor of n.
%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 For n = 2, a(2) = 2*3 + 1 = 7, because 2 is prime.
%e For n = 6, a(6) = 6 / 2 = 3, because 6 is composite; 2 is the smallest prime factor of 6.
%t a[n_]:=If[PrimeQ[n], 3n + 1, n/FactorInteger[n][[1, 1]]]; Table[a[n], {n, 2, 100}] (* _Indranil Ghosh_, Apr 22 2017 *)
%o (PARI) a(n) = if (isprime(n), 3*n+1, n/factor(n)[1,1]); \\ _Michel Marcus_, Jan 02 2016
%o (Python)
%o from sympy import isprime, primefactors
%o def a(n): return 3*n + 1 if isprime(n) else n//min(primefactors(n))
%o print([a(n) for n in range(2, 101)]) # _Indranil Ghosh_, Apr 22 2017
%Y Cf. A175871 (the repeating cycle starting at 2).
%Y Cf. A006370 (image of n under the 3x+1 map).
%K nonn
%O 2,1
%A _Robert C. Lyons_, Dec 31 2015