OFFSET
1,2
COMMENTS
Beginning with a(2) = 3, n such that exactly one of n - 1 and n + 1 is composite.
LINKS
G. C. Greubel, Table of n, a(n) for n = 1..10000
EXAMPLE
3 is in the sequence because 2 is prime but 4 is composite.
4 is not in the sequence because both 3 and 5 are prime.
5 is not in the sequence either because both 4 and 6 are composite.
MATHEMATICA
Select[Range[250], Xor[PrimeQ[# - 1], PrimeQ[# + 1]] &] (* G. C. Greubel, Apr 25 2019 *)
Module[{nn=Table[If[PrimeQ[n], 1, 0], {n, 0, 220}], t1, t2}, t1=Mean/@ SequencePosition[ nn, {1, _, 0}]; t2=Mean/@SequencePosition[nn, {0, _, 1}]; Flatten[ Join[t1, t2]]//Sort]-1 (* Harvey P. Dale, Jul 13 2019 *)
PROG
(PARI) for(n=1, 250, if(isprime(n-1)+isprime(n+1)==1, print1(n, ", ")))
(Magma) [n: n in [1..250] | IsPrime(n-1) xor IsPrime(n+1) ]; // G. C. Greubel, Apr 25 2019
(Sage) [n for n in (1..250) if (is_prime(n-1) + is_prime(n+1) == 1)] # G. C. Greubel, Apr 25 2019
CROSSREFS
KEYWORD
nonn
AUTHOR
Rick L. Shepherd, Nov 13 2004
STATUS
approved