cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

A100317 Numbers k such that exactly one of k - 1 and k + 1 is prime.

This page as a plain text file.
%I A100317 #19 Sep 08 2022 08:45:15
%S A100317 1,2,3,8,10,14,16,20,22,24,28,32,36,38,40,44,46,48,52,54,58,62,66,68,
%T A100317 70,74,78,80,82,84,88,90,96,98,100,104,106,110,112,114,126,128,130,
%U A100317 132,136,140,148,152,156,158,162,164,166,168,172,174,178,182,190,194,196,200
%N A100317 Numbers k such that exactly one of k - 1 and k + 1 is prime.
%C A100317 Beginning with a(2) = 3, n such that exactly one of n - 1 and n + 1 is composite.
%H A100317 G. C. Greubel, <a href="/A100317/b100317.txt">Table of n, a(n) for n = 1..10000</a>
%e A100317 3 is in the sequence because 2 is prime but 4 is composite.
%e A100317 4 is not in the sequence because both 3 and 5 are prime.
%e A100317 5 is not in the sequence either because both 4 and 6 are composite.
%t A100317 Select[Range[250], Xor[PrimeQ[# - 1], PrimeQ[# + 1]] &] (* _G. C. Greubel_, Apr 25 2019 *)
%t A100317 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 *)
%o A100317 (PARI) for(n=1,250,if(isprime(n-1)+isprime(n+1)==1,print1(n,",")))
%o A100317 (Magma) [n: n in [1..250] | IsPrime(n-1) xor IsPrime(n+1) ]; // _G. C. Greubel_, Apr 25 2019
%o A100317 (Sage) [n for n in (1..250) if (is_prime(n-1) + is_prime(n+1) == 1)] # _G. C. Greubel_, Apr 25 2019
%Y A100317 Cf. A100318 (at least one of n - 1 and n + 1 is composite).
%Y A100317 Cf. A001477, A169546, A171689, A099049, A014574 (no intersection with this sequence).
%K A100317 nonn
%O A100317 1,2
%A A100317 _Rick L. Shepherd_, Nov 13 2004