Reminder: The OEIS is hiring a new managing editor, and the application deadline is January 26.
%I #19 Dec 01 2020 05:52:30
%S 0,1,1,1,2,1,1,0,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,0,0,1,1,0,1,1,1,0,1,1,
%T 0,1,2,0,1,1,1,2,1,1,1,0,2,1,0,1,0,0,2,1,0,1,1,0,1,2,1,0,1,1,1,2,2,0,
%U 1,1,1,1,2,0,2,1,1,1,1,0,2,0,1,1,0,1,0
%N Number of 0 <= k <= sqrt(n) such that n-k and n+k are both prime.
%C Probably a(n) > N for any N and all sufficiently large n. Perhaps a(2591107) is the last 0 in this sequence. - _Charles R Greathouse IV_, Jan 30 2014
%C Primes p such that a(p)=1: 2, 3, 7, 11, 13, 17, 19, ... . _Juri-Stepan Gerasimov_, Feb 02 2014
%H T. D. Noe, <a href="/A236747/b236747.txt">Table of n, a(n) for n = 1..10000</a>
%F a(n) = Sum_{k=0..A000196(n)} (A010051(n-k) * A010051(n+k)). - _Antti Karttunen_, Feb 01 2014
%e a(3) = 1 because 3 - 0 = 3 and 3 + 0 = 3 are both prime for k = 0;
%e a(4) = 1 because 4 - 1 = 3 and 4 + 1 = 5 are both prime for k = 1 < sqrt(4) = 2;
%e a(5) = 2 because 5 - 0 = 5 and 5 + 0 = 5 are both prime for k = 0, 5 - 2 = 3 and 5 + 2 = 7 are both prime for k = 2 < sqrt(5).
%p A236767 := proc(n)
%p local a,k ;
%p a := 0 ;
%p for k from 0 to floor(sqrt(n)) do
%p if isprime(n-k) and isprime(n+k) then
%p a := a+1 ;
%p end if;
%p end do:
%p a ;
%p end proc:
%p seq(A236767(n),n=1..80) ; # _R. J. Mathar_, Dec 01 2020
%t Table[Length[Select[Range[0, Sqrt[n]], PrimeQ[n - #] && PrimeQ[n + #] &]], {n, 100}] (* _T. D. Noe_, Feb 01 2014 *)
%o (PARI) a(n)=sum(k=0,sqrtint(n),isprime(n-k)&&isprime(n+k)) \\ _Charles R Greathouse IV_, Jan 30 2014
%o (Scheme)
%o (define (A236747 n) (add (lambda (k) (* (A010051 (- n k)) (A010051 (+ n k)))) 0 (A000196 n)))
%o ;; The following implements sum_{i=lowlim..uplim} intfun(i):
%o (define (add intfun lowlim uplim) (let sumloop ((i lowlim) (res 0)) (cond ((> i uplim) res) (else (sumloop (1+ i) (+ res (intfun i)))))))
%o ;; From _Antti Karttunen_, Feb 01 2014
%Y Cf. A000196, A010051, A061357, A171637.
%K nonn
%O 1,5
%A _Juri-Stepan Gerasimov_, Jan 30 2014
%E Terms recomputed (with corrections) by _Antti Karttunen_, Feb 01 2014