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.
%I A300817 #24 Mar 14 2018 17:43:55 %S A300817 2,2,3,2,3,0,5,0,3,2,3,0,5,0,3,2,7,0,7,0,19,2,3,0,11,0,7,0,3,0,7,0,7, %T A300817 2,7,0,5,0,3,2,7,0,13,0,13,2,13,0,5,0,3,0,3,0,11,0,31,2,7,0,7,0,3,0,3, %U A300817 0,7,0,13,0,3,0,5,0,3,0,3,0,5,0,73,2,13,0,13,0,37,0,13,0 %N A300817 Smallest prime p such that p + n^2 is prime, or 0 if no such prime exists. %C A300817 a(n) = 0 if n is a member of A106571. %H A300817 Robert Israel, <a href="/A300817/b300817.txt">Table of n, a(n) for n = 0..10000</a> %e A300817 For n = 16: %e A300817 2 + 16^2 is not prime; %e A300817 3 + 16^2 = 7*37 is not prime; %e A300817 5 + 16^2 = 3*87 is not prime; %e A300817 7 + 16^2 = 263 is prime, therefore a(16) = 7. %p A300817 A300817 := proc(n) local p, n2; p := 2; n2 := n^2; %p A300817 if irem(n2, 2) = 1 and numtheory:-invphi(n2+1) = [] then return 0 fi; %p A300817 do if isprime(p + n2) then return p fi; p := nextprime(p) od; %p A300817 end: seq(A300817(n), n = 0..89); # _Peter Luschny_, Mar 13 2018 %t A300817 a[n_] := Block[{p=2}, If[OddQ[n], If[PrimeQ[n^2 + 2], 2, 0], While[! PrimeQ[n^2 + p], p = NextPrime[p]]; p]]; a /@ Range[0, 89] (* _Giovanni Resta_, Mar 13 2018 *) %o A300817 (Julia) %o A300817 using Primes %o A300817 function A300817(n) p, q = 2, n * n %o A300817 n % 2 == 1 && return isprime(p + q) ? 2 : 0 %o A300817 while !isprime(p + q) p = nextprime(p + 1) end %o A300817 p end %o A300817 [A300817(n) for n in 0:89] |> println # _Peter Luschny_, Mar 13 2018 %o A300817 (Python) %o A300817 from sympy import nextprime, isprime %o A300817 def A300817(n): %o A300817 p, n2 = 2, n**2 %o A300817 if n % 2: %o A300817 return 2 if isprime(2+n2) else 0 %o A300817 while not isprime(p+n2): %o A300817 p = nextprime(p) %o A300817 return p # _Chai Wah Wu_, Mar 14 2018 %o A300817 (PARI) A300817(n)={if(bittest(n,0), n=n^2; forprime(p=2,, isprime(2+n)&&return(p)), isprime(2+n^2)*2)} \\ _M. F. Hasler_, Mar 14 2018 %Y A300817 Cf. A087242: smallest prime p such that p + n is prime. %Y A300817 Cf. A174960: smallest prime p such that p + n*(n+1)/2 is prime. %Y A300817 Cf. A106571. %K A300817 nonn %O A300817 0,1 %A A300817 _Bruno Berselli_, Mar 13 2018