%I #20 Nov 02 2025 12:22:53
%S 3,4,1,2,24,4,24,1,32,12,48,2,216,12,8,3,264,16,72,6,8,24,96,1,408,
%T 108,104,6,120,4,120,9,16,132,24,8,144,36,72,3,168,4,696,12,8,48,1680,
%U 1,192,204,88,54,216,52,144,3,24,60,2112,2,2208,60,80,15,96,8,1080,66,32,12
%N Least positive integer m such that m*n + 1 = p^2 for some prime number p.
%C a(n) always exists since there are (infinitely many) primes p congruent to 1 modulo n.
%C Conjecture: a(n) <= (n+5)*(n-1) for all n > 1 (verified for n <= 12000).
%H Zhi-Wei Sun, <a href="/A390118/b390118.txt">Table of n, a(n) for n = 1..4000</a>
%e a(1) = 3 since 3*1 + 1 = 2^2 and 2 is prime.
%e a(2) = 4 since 4*2 + 1 = 3^2 and 3 is prime.
%e a(13) = 216 = (13+5)*(13-1) since 216*13 + 1 = 53^2 and 53 is prime.
%t PQ[n_]:=PQ[n]=PrimeQ[Sqrt[n]];
%t tab={};Do[m=1;Label[bb];If[PQ[m*n+1],tab=Append[tab,m];Goto[aa]];
%t m=m+1;Goto[bb];Label[aa],{n,1,70}];Print[tab]
%o (PARI) a(n) = my(m=1); while (isprimepower(m*n+1) != 2, m++); m; \\ _Michel Marcus_, Nov 02 2025
%o (Python)
%o from math import isqrt
%o from sympy import isprime
%o from itertools import count
%o def a(n): return next(m for m in count(1) if (p:=isqrt(q:=m*n+1))**2==q and isprime(p))
%o print([a(n) for n in range(1, 71)]) # _Michael S. Branicky_, Nov 02 2025
%Y Cf. A000040, A001248, A034693, A390117.
%K nonn
%O 1,1
%A _Zhi-Wei Sun_, Oct 25 2025