login
a(n) is the least nonnegative integer such that n + i*a(n) is a Gaussian prime.
1

%I #38 Feb 27 2018 16:23:46

%S 3,1,1,0,1,2,1,0,3,4,1,0,7,2,1,2,1,2,5,0,1,4,5,0,1,4,1,2,5,4,11,0,3,2,

%T 5,2,1,2,3,10,1,4,5,0,9,2,5,0,13,4,7,4,3,10,1,4,1,2,3,0,13,10,3,32,9,

%U 2,1,0,5,10,3,0,5,2,1,4,5,10,7,0,7,4,3,0,1,2,9,2,3,4,1,4,7,8,1,2,5,2,3,4,3

%N a(n) is the least nonnegative integer such that n + i*a(n) is a Gaussian prime.

%H Lars-Erik Svahn, <a href="/A284376/b284376.txt">Table of n, a(n) for n = 0..10000</a>

%H Lars-Erik Svahn, <a href="https://github.com/Lehs/ANS-Forth-libraries">numbertheory.4th</a>

%H Akshaa Vatwani, <a href="http://dx.doi.org/10.1016/j.jnt.2016.07.008">Bounded gaps between Gaussian primes</a>, Journal of Number Theory, Volume 171, February 2017, Pages 449-473.

%H Wikipedia, <a href="https://en.wikipedia.org/wiki/Gaussian_integer#Gaussian_primes">Gaussian prime</a>

%H <a href="/index/Ga#gaussians">Index entries for Gaussian integers and primes</a>

%F From _Michel Marcus_, Mar 30 2017: (Start)

%F a(n) = 0 for n in A002145.

%F a(n) = 1 for n in A005574.

%F (End)

%F a(n) = A069003(n) if n is not in A002145. - _Robert Israel_, Apr 07 2017

%p f:= proc(n) local k;

%p for k from 0 do if GaussInt:-GIprime(n+I*k) then return k fi od

%p end proc:

%p map(f, [$0..100]); # _Robert Israel_, Apr 07 2017

%t Table[k = 0; While[! PrimeQ[n + I k, GaussianIntegers -> True], k++]; k, {n, 0, 100}] (* _Michael De Vlieger_, Mar 29 2017 *)

%o (ANS-Forth)

%o s" numbertheory.4th" included

%o : 3mod4_prime \ n -- flag

%o abs dup isprime swap 3 and 3 = and ;

%o : isGaussianPrime \ a b -- flag

%o over 0= if nip 3mod4_prime exit then

%o dup 0= if drop 3mod4_prime exit then

%o dup * swap dup * + isprime ;

%o : Gauss_prime \ n -- a(n)

%o 0

%o begin 2dup isGaussianPrime 0=

%o while 1+

%o repeat nip ;

%Y Cf. A002145, A005574, A069003.

%K nonn

%O 0,1

%A _Lars-Erik Svahn_, Mar 25 2017