A176462
Numbers k such that neither k-1 nor k+1 is prime or semiprime.
Original entry on oeis.org
0, 17, 19, 29, 31, 41, 43, 49, 51, 53, 55, 65, 67, 69, 71, 77, 79, 89, 91, 97, 99, 101, 103, 109, 111, 113, 115, 125, 127, 129, 131, 137, 139, 149, 151, 153, 155, 161, 163, 169, 171, 173, 175, 181, 183, 185, 187, 189, 191, 197, 199, 209, 211, 221, 223, 229, 231
Offset: 1
0 is a term because neither 0-1=-1 nor 0+1=1 is prime or semiprime.
-
isA001358 := proc(n) numtheory[bigomega](n) = 2 ; end proc: for n from 0 to 400 do if isA001358(n+1) or isA001358(n-1) or isprime(n+1) or isprime(n-1) then ; else printf("%d,",n) ; end if; end do: # R. J. Mathar, Apr 20 2010
-
Join[{0},Flatten[Position[Partition[Table[If[PrimeQ[n]||PrimeOmega[n] == 2,1,0],{n,250}],3,1],?(#[[1]]==#[[3]]==0&),{1},Heads -> False]]+ 1] (* _Harvey P. Dale, Oct 27 2015 *)
A343730
a(n) is the length of the longest run of consecutive integers centered at n/2 with primality symmetric about n/2, or 0 if no such run exists.
Original entry on oeis.org
2, 1, 0, 1, 4, 1, 0, 3, 0, 5, 0, 5, 0, 3, 0, 1, 2, 11, 2, 1, 0, 3, 0, 17, 0, 3, 0, 1, 2, 19, 2, 1, 0, 3, 0, 13, 0, 3, 0, 1, 2, 7, 2, 1, 0, 7, 0, 1, 2, 3, 4, 9, 4, 3, 2, 1, 0, 3, 0, 37, 0, 3, 0, 1, 2, 3, 4, 9, 4, 3, 2, 1, 0, 7, 0, 1, 2, 7, 2, 1, 0, 3, 0, 25, 0
Offset: 1
For n=1, the shortest run of consecutive integers centered at 1/2 is {0, 1}; both are nonprime, so its primality is symmetric about its center. The next longer run of consecutive integers centered at 1/2 is {-1, 0, 1, 2}; 2 is prime, but -1 is not, so this run's primality is not symmetric about its center, and the same will be true of any longer run centered at 1/2 (e.g., {-2, -1, 0, 1, 2, 3}). So the longest run with primality symmetric about 1/2 is {0, 1}, whose length is 2, so a(1)=2.
For n=2, the "run" of length 1 centered at 2/2 = 1 is simply {1} (and, like every run of length 1, has primality symmetric about its center). The run of length 3 centered at 1 is {0, 1, 2}; 2 is prime, but 0 is not, so a(2)=1.
For n=3, the shortest run of consecutive integers centered at 3/2 is {1, 2}, whose primality is not symmetric about the center (2 is prime while 1 is not), and the same will be true of any longer run centered at 3/2, so no run with primality symmetric about 3/2 exists, so a(3)=0.
For n=5, the run {2, 3} has symmetric primality (both 2 and 3 are prime), and so does {1, 2, 3, 4} (both 1 and 4 are nonprime), but {0, 1, 2, 3, 4, 5} does not (5 is prime, 0 is not), so a(5)=4.
For n=18, the run of length 11 centered at 18/2 = 9 is
4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14
with primality 0, 1, 0, 1, 0, 0, 0, 1, 0, 1, 0,
which is symmetric, but the run of length 13 is not (since 3 is prime while 15 is not), so a(18)=11.
-
Table[s=If[OddQ@n,{Floor[n/2],Ceiling[n/2]},{n/2-1,n/2+1}];k=0;While[SameQ@@PrimeQ@s,k++;s=s+{-1,+1}];If[OddQ@n,2k,2k+1],{n,85}] (* Giorgos Kalogeropoulos, Sep 23 2021 *)
-
a(n) = {my (nb = 0, fL, fR); fL = n\2; if (n%2, fR = fL+1, fL--; fR = fL+2); for (i=0, oo, if (isprime(fL-i) != isprime(fR+i), break, nb++);); if (n%2, 2*nb, 2*nb+1);} \\ Michel Marcus, Sep 23 2021
-
from sympy import isprime
def ispal(s):
return s == s[::-1]
def primestr(a, b):
return "".join('1' if isprime(k) else '0' for k in range(a, b+1))
def a(n):
fl, cg = n//2, (n+1)//2
start, end, r = fl, cg, n%2-1
while ispal(primestr(start, end)):
start, end, r = start-1, end+1, r+2
return r
print([a(n) for n in range(1, 86)]) # Michael S. Branicky, Sep 23 2021
Showing 1-2 of 2 results.
Comments