login
a(n) is the least prime q such that q*(n+1)-n is the square of a prime.
2

%I #18 Jan 04 2022 04:09:17

%S 5,2,3,73,5,241,2,41,13,409,3,1321,13,113,19,601,17,73,7,41,541,97,2,

%T 409,109,97081,7,1033,5,3121,31,17,313,937,11,601,37,73,43,5881,5,

%U 20857,13,113,409,9241,2,193,457,89,331,17137,53,313,31,401,61,2113,3,3889,61,257,571,97,29,241321

%N a(n) is the least prime q such that q*(n+1)-n is the square of a prime.

%H Robert Israel, <a href="/A350518/b350518.txt">Table of n, a(n) for n = 1..10000</a>

%F a(n)*(n+1)-n = A350517(n)^2.

%e a(4) = 73 because 73 is prime, 73*(4+1)-4 = 361 = 19^2 where 19 is prime, and no smaller prime than 73 works.

%p g:= proc(n) local p, M, a, m, q;

%p M:= sort(map(t -> rhs(op(t)), [msolve(p^2=1, n+1)]));

%p for a from 0 do

%p for m in M do

%p p:= a*(n+1)+m;

%p if not isprime(p) then next fi;

%p q:= (p^2+n)/(n+1);

%p if isprime(q) then return q fi

%p od od:

%p end proc:

%p map(g, [$1..100]);

%t a[n_] := Module[{q = 2, p}, While[! IntegerQ[(p = Sqrt [q*(n + 1) - n])] || ! PrimeQ[p], q = NextPrime[q]]; q]; Array[a, 70] (* _Amiram Eldar_, Jan 03 2022 *)

%o (PARI) a(n) = my(q=2, p); while(! (issquare(q*(n+1)-n, &p) && isprime(p)), q = nextprime(q+1)); q; \\ _Michel Marcus_, Jan 03 2022

%o (Python)

%o from sympy import integer_nthroot, isprime, nextprime

%o def A350518(n):

%o q = 2

%o while True:

%o a, b = integer_nthroot(q*(n+1)-n,2)

%o if b and isprime(a):

%o return q

%o q = nextprime(q) # _Chai Wah Wu_, Jan 04 2022

%Y Cf. A350517.

%K nonn

%O 1,1

%A _J. M. Bergot_ and _Robert Israel_, Jan 02 2022