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.

A347986 Length of identical sequence of prime / nonprime numbers left and right of the integer n (excluded).

This page as a plain text file.
%I A347986 #43 Mar 28 2024 10:53:55
%S A347986 0,0,0,1,2,2,1,0,5,0,1,8,1,0,9,0,1,6,1,0,3,0,3,0,1,4,1,0,1,18,1,0,1,4,
%T A347986 1,0,3,0,3,0,1,12,1,0,3,0,3,0,1,6,1,0,7,0,1,4,1,0,1,10,1,0,1,4,1,0,3,
%U A347986 0,3,0,1,4,1,0,1,4,1,0,3,0,9,0,3,0,1,6,1,0,5,0,1,2,7,2,1,0,3,0,3
%N A347986 Length of identical sequence of prime / nonprime numbers left and right of the integer n (excluded).
%F A347986 From _Jon E. Schoenfield_, Sep 22 2021: (Start)
%F A347986 a(n) = Max_{k : A010051(n-j) = A010051(n+j) for 0 <= j <= k}.
%F A347986 a(n) = (A343730(2*n) - 1)/2. (End)
%e A347986 For n=2 (first useful term) the result is 0 because 2 is preceded by 1 which is by definition nonprime and succeeded by 3 which is prime meaning symmetry is broken right away. A better example may be 5 with a value of 2. The two numbers preceding 5 are 3, 4: prime, nonprime and the succeeding values are 6 and 7 being nonprime and prime. In other words, starting from 5 as center, the first positions are 4 (left) and 6 (right), both nonprimes. The next positions are 3 and 7, both primes. The sequence is now 2 long. It breaks after that because 2 is prime but 8 is nonprime. So we note 2 or 5. Very interesting is 30 which has a sequence of 18 on each side that follow the same pattern.
%e A347986 From _Jon E. Schoenfield_, Sep 22 2021: (Start)
%e A347986 As shown in the illustration below, where P and N denote prime and nonprime, respectively, the distribution of primes and nonprimes around n=21 is symmetrical in the interval [18, 24] = [21-3, 21+3], but not in the interval [17, 25] = [21-4, 21+4] (since 17 is prime but 25 is composite), so a(21) = 3:
%e A347986 .
%e A347986               |<------- 3 -------->|<------- 3 -------->|
%e A347986       17     18     19     20     21     22     23     24     25
%e A347986   -----+------+------+------+------+------+------+------+------+-----
%e A347986        P      N      P      N      N      N      P      N      N
%e A347986               |      |      |             |      |      |
%e A347986               |      |      +-------------+      |      |
%e A347986               |      +---------------------------+      |
%e A347986               +-----------------------------------------+
%e A347986 (End)
%t A347986 Table[s={n-1,n+1};k=0;While[SameQ@@PrimeQ@s,k++;s=s+{-1,+1}];k,{n,2,85}] (* _Giorgos Kalogeropoulos_, Sep 23 2021 *)
%o A347986 (Python)
%o A347986 from sympy import *
%o A347986 seq_pole = []
%o A347986 seq_pole.append(-1) #0
%o A347986 seq_pole.append(-1) #1
%o A347986 for i in range(1, 1000):
%o A347986     d = 1
%o A347986     #  Check how far the left is identical to the
%o A347986     # (mirrored) right
%o A347986     while isprime(i-d) == isprime(i+d):
%o A347986         d = d + 1
%o A347986     dmax = d - 1
%o A347986     seq_pole.append(dmax)
%o A347986     # i is the center (index) and dmax is the max extent
%o A347986     # on each side that is the same (or mirrored at i if you will)
%o A347986     print("{}".format(dmax))
%o A347986 (PARI) f(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);} \\ A343730
%o A347986 a(n) = (f(2*n) - 1)/2; \\ _Michel Marcus_, Sep 24 2021
%Y A347986 Cf. A343730, A346399 (number of primes in the interval n +- a(n)).
%K A347986 nonn
%O A347986 1,5
%A A347986 _Lothar Esser_, Sep 22 2021
%E A347986 More terms from _Michel Marcus_, Sep 24 2021