login
Numbers k such that k^2 + 1 = p*q, p and q primes and |p-q| is square.
1

%I #25 Mar 07 2020 12:24:48

%S 30,100,144,274,484,516,526,756,1046,1250,1714,1806,1834,2284,2440,

%T 2610,2940,3524,3824,4190,5084,5746,6766,7486,9746,9920,10310,13024,

%U 13210,15396,16916,17546,18726,19256,20000,21194,23214,24964,30370,30394,31126,31496,35180,36680,37816

%N Numbers k such that k^2 + 1 = p*q, p and q primes and |p-q| is square.

%C Note that if k^2+1 = p*q, then p+q cannot be a square. Proof by contradiction. There are two cases: p an odd prime and p=2. Case 1: suppose p and q are odd primes and q = y^2-p. Note that y must be an even number in order for q to be odd. Then p(y^2-p) = x^2+1 for some even x. Rearranging terms, we obtain p*y^2-1 = p^2+x^2. Looking at this equation modulo 4, we obtain -1 = 1, a contradiction. Case 2: Let p=2. Then we obtain 2y^2-x^2 = 5, which has no solutions in integers. - _T. D. Noe_, Mar 10 2011

%H Robert Israel, <a href="/A187401/b187401.txt">Table of n, a(n) for n = 1..600</a>

%e 20000 is in the sequence because 20000^2+1 = 19801 * 20201 and 20201 - 19801 = 20^2.

%p with(numtheory):nn:=50000:for i from 1 to nn do: n:=i^2+1:x:=factorset(n):x1:=nops(x):x2:=bigomega(n):if x1=2 and x2=2 then z:=x[2]-x[1] :w:=sqrt(z):if w= floor(w) then printf(`%d, `, i):else fi:else fi :od:

%p # Alternative:

%p N:= 500: # to get a(1) to a(N)

%p count:= 0:

%p for k from 2 by 2 while count < N do

%p f:= ifactors(k^2+1)[2];

%p if nops(f) = 2 and {f[1,2],f[2,2]}={1} and issqr(abs(f[1,1]-f[2,1])) then

%p count:= count+1;

%p A[count]:= k;

%p fi

%p od:

%p seq(A[i],i=1..count); # _Robert Israel_, Jun 09 2014

%t okQ[k_] := Module[{ff = FactorInteger[k^2+1]}, Length[ff] == 2 && ff[[All, 2]] == {1, 1} && IntegerQ[Sqrt[ff[[2, 1]] - ff[[1, 1]]]]];

%t Select[Range[2, 40000, 2], okQ] (* _Jean-François Alcover_, Jun 25 2019 *)

%o (Sage)

%o A = []

%o for k in range(2, 2000, 2):

%o K = k^2 + 1

%o f = prime_divisors(K)

%o if len(f) == 2:

%o if mul(f) == K:

%o if is_square(abs(f[0]-f[1])):

%o A.append(k)

%o print(A) # _Peter Luschny_, Jun 10 2014

%Y Cf. A134406, A134407, A002522, A005574.

%K nonn

%O 1,1

%A _Michel Lagneau_, Mar 09 2011