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.

A236747 Number of 0 <= k <= sqrt(n) such that n-k and n+k are both prime.

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