login
Values of N for which the equation x^2 - 4*y^2 = N has integer solutions.
5

%I #32 Nov 24 2024 10:39:47

%S 0,1,4,5,9,12,13,16,17,20,21,25,28,29,32,33,36,37,41,44,45,48,49,52,

%T 53,57,60,61,64,65,68,69,73,76,77,80,81,84,85,89,92,93,96,97,100,101,

%U 105,108,109,112,113,116,117,121,124,125,128,129,132,133,137

%N Values of N for which the equation x^2 - 4*y^2 = N has integer solutions.

%C This equation is a Pellian equation of the form x^2 - D^2*y^2 = N. A042965 covers the case D=1.

%C This sequence is also numbers that are congruent to {0,1,4,5,9,12,13} mod 16.

%H Bruno Berselli, <a href="/A230239/b230239.txt">Table of n, a(n) for n = 1..1000</a>

%H <a href="/index/Rec#order_08">Index entries for linear recurrences with constant coefficients</a>, signature (1,0,0,0,0,0,1,-1).

%F G.f.: x^2*(x+1)*(3*x+1)*(x^2-x+1)*(x^2+1) / ((x-1)^2*(x^6+x^5+x^4+x^3+x^2+x+1)).

%F a(n) ~ 16*n/7. - _Stefano Spezia_, Apr 08 2024

%F a(n) = 2*floor((4*n+1)/7) + floor((n+3)/7) + n. - _Ridouane Oudra_, Nov 24 2024

%e For N=33, the equation x^2 - 4*y^2 = 33 has solutions (X,Y) = (7,2) and (17,8).

%p seq(2*floor((4*n+1)/7)+floor((n+3)/7)+n, n=0..80); # _Ridouane Oudra_, Nov 24 2024

%o (PARI)

%o \\ Values of n for which the equation x^2 - d^2*y^2 = n has integer solutions.

%o \\ e.g. allpellsq(2, 20) gives [0,1,4,5,9,12,13,16,17,20]

%o allpellsq(d, nmax) = {

%o local(v=[0], n, w);

%o for(n=1, nmax,

%o w=pellsq(d, n);

%o if(#w>0, v=concat(v, n))

%o );

%o v

%o }

%o \\ All integer solutions to x^2-d^2*y^2=n.

%o \\ e.g. pellsq(5, 5200) gives [265,51;140,24;85,9]

%o pellsq(d, n) = {

%o local(m=Mat(), f, x, y);

%o fordiv(n, f,

%o if(f*f>n, break);

%o if((n-f^2)%(2*f*d)==0,

%o y=(n-f^2)\(2*f*d);

%o x=d*y+f;

%o m=concat(m, [x,y]~)

%o )

%o );

%o m~

%o }

%Y Cf. A042965, A230240.

%K nonn,easy

%O 1,3

%A _Colin Barker_, Oct 13 2013