login
The OEIS is supported by the many generous donors to the OEIS Foundation.

 

Logo
Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A127356 a(n) is the smallest k > 0 such that k^2 + prime(n) is prime. 4

%I #23 Nov 12 2022 02:10:21

%S 1,2,6,2,6,2,6,2,6,12,4,2,24,2,6,6,18,6,2,6,4,2,12,12,2,6,2,12,2,6,2,

%T 6,6,10,12,4,4,2,12,12,18,4,6,2,6,8,4,2,6,2,6,12,4,24,6,18,18,6,2,6,8,

%U 18,2,6,2,6,4,4,6,2,6,12,4,4,2,6,30,2,24,10

%N a(n) is the smallest k > 0 such that k^2 + prime(n) is prime.

%C All terms apart from the first need to be even because all primes but the first one have the same parity. Record values 1, 2, 6, 12, 24, 30, 42, 54, 60, 66, 90, 132, 138, 210, 270, ... are set at n=1, 2, 3, 10, 13, 77, 92, 152, 294, 484, 517, 964, 1203, 2876, 14118, ... - _R. J. Mathar_, Apr 02 2007

%C a(n) exists for all n on the Hardy-Littlewood conjecture F. - _Charles R Greathouse IV_, Jul 26 2012

%H Zak Seidov, <a href="/A127356/b127356.txt">Table of n, a(n) for n = 1..1000</a>

%e 17 = prime(7); 17 + 1^2 = 18, 17 + 2^2 = 21, 17 + 3^2 = 26, 17 + 4^2 = 33, 17 + 5^2 = 42 are all composite, but 17 + 6^2 = 53 is prime. Hence a(7) = 6.

%p a:=proc(n) local A,j: A:={}: for j from 1 to 50 do if isprime(ithprime(n)+j^2)=true then A:=A union {j} else A:=A fi od: A[1]: end: seq(a(n),n=1..120); # _Emeric Deutsch_, Apr 01 2007

%p A127356 := proc(n) local p,a; p := ithprime(n) ; a := 1 ; while not isprime(p+a^2) do a := a+1 ; od ; RETURN(a) ; end: for n from 1 to 120 do printf("%d,",A127356(n)) ; od ; # _R. J. Mathar_, Apr 02 2007

%t Join[{1},Table[p=Prime[n];x=2;While[!PrimeQ[a=p+x^2],x=x+2]; x,{n,2,100}]] (* _Zak Seidov_, Oct 12 2012 *)

%t sk[n_]:=Module[{k=2},While[!PrimeQ[n+k^2],k=k+2];k]; Join[{1},Table[sk[n],{n,Prime[Range[2,80]]}]] (* _Harvey P. Dale_, Jul 26 2017 *)

%o (PARI) {for(n=1, 93, p=prime(n); k=1; while(!isprime(p+k^2), k++); print1(k, ","))} /* _Klaus Brockhaus_, Apr 05 2007 */

%o (Python)

%o from sympy import isprime, nextprime, prime

%o def a(n):

%o if n == 1: return 1

%o k, pn = 2, prime(n)

%o while not isprime(pn + k*k): k += 2

%o return k

%o print([a(n) for n in range(1, 81)]) # _Michael S. Branicky_, Nov 11 2022

%Y Cf. A000040 (the primes), A000290 (the squares).

%K nonn

%O 1,2

%A _J. M. Bergot_, Mar 30 2007

%E Edited, corrected and extended by _Emeric Deutsch_, _R. J. Mathar_ and _Klaus Brockhaus_, Apr 01 2007

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recents
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified April 24 20:08 EDT 2024. Contains 371963 sequences. (Running on oeis4.)