login
a(n) = A007918(A138750(n)), that is, least prime > n/2 if n=2 (mod 3), > 2n otherwise.
2

%I #21 May 17 2023 13:00:22

%S 2,2,2,7,11,3,13,17,5,19,23,7,29,29,7,31,37,11,37,41,11,43,47,13,53,

%T 53,13,59,59,17,61,67,17,67,71,19,73,79,19,79,83,23,89,89,23,97,97,29,

%U 97,101,29,103,107,29,109,113,29,127,127,31,127,127,31,127

%N a(n) = A007918(A138750(n)), that is, least prime > n/2 if n=2 (mod 3), > 2n otherwise.

%C This can be considered as an analog of the Collatz (or 3n+1) map on the set of primes, see A138751 and A138754 for details.

%C Numbers 0,1,2 go immediately to the unique fixed point 2, all others end up in the cycle 7 -> 17 -> 11 -> 7, after a number of iterations given by A138753(A138757(n))-1 (= A138753(n)-2 if n is prime).

%H Georges Brougnard, <a href="https://www.echolalie.org/echolaliste/gbnums/gb0.jpg">Definition of GB-sequences</a>.

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

%F a(n) = A007918(A138750(n)).

%F For p prime, a(p) = A138751(A000720(p))

%e a(7) = 17 since 7 = 1 (mod 3), thus A138750(7) = 2*7 = 14, nextprime(14) = 17.

%e a(11) = 7 since 11 = 2 (mod 3), thus A138750(11) = ceiling(11/2) = 6, nextprime(6) = 7.

%t np1[n_]:=Module[{x=Ceiling[n/2]},If[PrimeQ[x],x,NextPrime[x]]]; np2[n_]:= Module[{x=2n},If[PrimeQ[x],x,NextPrime[x]]]; Table[If[Mod[n,3]==2, np1[n], np2[n]],{n,0,70}] (* _Harvey P. Dale_, Jul 10 2013 *)

%o (PARI) A138757(n)=nextprime(if(n%3==2,(n+1)\2,2*n))

%Y Cf. A124123, A138750, A138751, A138752, A138753, A138754, A138755, A138756, A007918.

%K easy,nonn

%O 0,1

%A _M. F. Hasler_, Apr 04 2008