A284278 a(1)=2; for n >= 1, if n+2 is prime then a(2*n+1) = 3*n + 2 and a(2*n) = n + 2, otherwise all terms are 2.
2, 3, 5, 4, 2, 5, 9, 6, 2, 7, 13, 8, 2, 9, 2, 10, 2, 11, 21, 12, 2, 13, 25, 14, 2, 15, 2, 16, 2, 17, 33, 18, 2, 19, 37, 20, 2, 21, 2, 22, 2, 23, 45, 24, 2, 25, 2, 26, 2, 27, 2, 28, 2, 29, 57, 30, 2, 31, 61, 32, 2, 33, 2, 34, 2, 35, 2, 36, 2, 37, 73, 38, 2, 39
Offset: 1
Keywords
Examples
For n=19, a(38) = a(2*19) = 19+2 = 21, a(39) = a(2*19+1) = 2, the latter since 19+2 is not prime; for n=21, a(42) = a(2*21) = 21+2 = 23, a(43) = a(2*21+1) = 2*21+3 = 45 since 21+2 is prime.
Links
- Michael De Vlieger, Table of n, a(n) for n = 1..10000
- Michael De Vlieger, Log-log scatterplot of a(n) for n=1..2^12.
Crossrefs
Cf. A284172.
Programs
-
Mathematica
a[1]:=2; a[n_?EvenQ]:=n/2+2; a[n_?OddQ]:=If[PrimeQ[(n+1)/2+1], n+2, 2]; Map[a, Range[150]] (* Peter J. C. Moses, Mar 24 2017 *)
-
PARI
a(n) = if(n<2, 2, if(n%2, if(isprime((n + 1)/2 + 1), n + 2, 2), (n/2 + 2))); \\ Indranil Ghosh, Mar 25 2017
Extensions
More terms from Peter J. C. Moses, Mar 24 2017
Comments