login
The OEIS Foundation is supported by donations from users of the OEIS and by a grant from the Simons Foundation.

 

Logo

Thanks to everyone who made a donation during our annual appeal!
To see the list of donors, or make a donation, see the OEIS Foundation home page.

Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A243145 Least positive number k such that n+k and n+k^2 are both prime. 3
1, 1, 2, 1, 6, 1, 4, 3, 2, 1, 6, 1, 4, 3, 2, 1, 6, 1, 12, 3, 16, 1, 6, 7, 4, 15, 2, 1, 12, 1, 6, 9, 8, 3, 6, 1, 4, 3, 2, 1, 30, 1, 4, 3, 8, 1, 6, 5, 10, 3, 10, 1, 6, 5, 4, 15, 2, 1, 42, 1, 6, 21, 4, 3, 6, 1, 4, 15, 2, 1, 30, 1, 6, 33, 8, 25, 6, 1, 10, 3, 16, 1, 24, 5, 4, 15 (list; graph; refs; listen; history; text; internal format)
OFFSET

1,3

COMMENTS

For n > 1, a(n) == n+1 (mod 2). a(n) = 1 for n in A006093. - Robert Israel, Feb 02 2018

LINKS

Robert Israel, Table of n, a(n) for n = 1..10000

EXAMPLE

8+1 and 8+1^2 (9) isn't prime. 8+2 and 8+2^2 (10 and 12) aren't both prime. But 8+3 and 8+3^2 (11 and 17) are both prime. Thus a(8) = 3.

MAPLE

f:= proc(n) local k;

  for k from (n mod 2)+1 by 2 do

    if isprime(n+k) and isprime(n+k^2) then return k fi

  od

end proc:

f(1):= 1:

map(f, [$1..100]); # Robert Israel, Feb 02 2018

MATHEMATICA

f[n_] := Module[{k}, For[k = Mod[n, 2] + 1, True, k += 2, If[PrimeQ[n + k] && PrimeQ[n + k^2], Return[k]]]]; f[1] = 1; f /@ Range[100] (* Jean-Fran├žois Alcover, Feb 03 2018, after Robert Israel *)

PROG

(PARI) a(n)=for(k=1, 10^6, if(ispseudoprime(n+k)&&ispseudoprime(n+k^2), return(k)))

n=1; while(n<100, print1(a(n), ", "); n+=1)

(Python)

from sympy import isprime, nextprime

def A243145(n):

    m = n

    while True:

        m = nextprime(m)

        k = m-n

        if isprime(n+k**2):

            return k #  Chai Wah Wu, Sep 03 2019

CROSSREFS

Cf. A006093.

Sequence in context: A321725 A154744 A285038 * A306695 A242926 A189733

Adjacent sequences:  A243142 A243143 A243144 * A243146 A243147 A243148

KEYWORD

nonn

AUTHOR

Derek Orr, May 30 2014

STATUS

approved

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

License Agreements, Terms of Use, Privacy Policy. .

Last modified January 21 16:54 EST 2020. Contains 331114 sequences. (Running on oeis4.)