OFFSET
1,3
COMMENTS
n + i*a(n) and n + i*(a(n) - 2) are Gaussian twin primes.
If n^2 + 1 is a prime then a(n) = 1 else a(n) = A284211(n) + 2.
LINKS
Lars-Erik Svahn, Table of n, a(n) for n = 1..99
Lars-Erik Svahn, numbertheory.4th
Akshaa Vatwani, Bounded gaps between Gaussian primes, Journal of Number Theory, Volume 171, February 2017, Pages 449-473.
Eric Weisstein's World of Mathematics, Gaussian prime
FORMULA
a(n) = 1 for n in A005574. - Michel Marcus, Mar 31 2017
EXAMPLE
a(1) = 1 since 1^2 + 1^2 = 2 and 1^2 + (1 - 2)^2 = 2 are primes.
MATHEMATICA
Rest@ FoldList[Module[{k = 1}, While[Times @@ Boole@ Map[PrimeQ, {#2^2 + k^2, #2^2 + (k - 2)^2}] < 1, k++]; k] &, 1, Range@ 71] (* Michael De Vlieger, Mar 25 2017 *)
PROG
(ANS-Forth)
s" numbertheory.4th" included
: Gauss_twins \ n -- a(n)
dup * locals| square | 0
begin 1+ dup dup * square + isprime
over 2 - dup * square + isprime and
until ;
(PARI) a(n) = k=0; while (! (isprime(n^2+k^2) && isprime(n^2+(k-2)^2)), k++); k; \\ Michel Marcus, Mar 25 2017
(Python)
from sympy import isprime
def a(n):
k=0
while True:
if isprime(n**2 + k**2) and isprime(n**2 + (k - 2)**2): return k
else: k+=1
print([a(n) for n in range(1, 101)]) # Indranil Ghosh, Mar 31 2017
CROSSREFS
KEYWORD
nonn
AUTHOR
Lars-Erik Svahn, Mar 25 2017
STATUS
approved