%I #29 Apr 24 2024 13:21:51
%S 0,1,2,3,18,4,5,70,6,32,7,182,99,29718,8,1068,43,9,378,500,5604,10,
%T 4005,8890182,776,11,682,57,1744,12,113582,4832118,13,1118,1111225770,
%U 68,1764132,14,3141,251,15,1710,23156,71011068,4443,16,6072,82,1407
%N Smallest integer x satisfying the Pell equation x^2-k*y^2=-1 for the values of k given in A031396.
%H Ray Chandler, <a href="/A130226/b130226.txt">Table of n, a(n) for n = 1..10000</a>
%H K. Lakshmi and R. Someshwari, <a href="https://www.ijeter.everscience.org/Manuscripts/Volume-4/Issue-7/Vol-4-issue-7-M-02.pdf">On The Negative Pell Equation y^2 = 72x^2 - 23</a>, International Journal of Emerging Technologies in Engineering Research (IJETER), Volume 4, Issue 7, July (2016).
%H R. Suganya and D. Maheswari, <a href="http://dx.doi.org/10.22457/jmi.v11a9">On the Negative Pellian Equation y^2 = 110 * x^2 - 29</a>, Journal of Mathematics and Informatics, Vol. 11 (2017), pp. 63-71.
%H S. Vidhyalakshmi, V. Krithika, and K. Agalya, <a href="http://www.ijeter.everscience.org/Manuscripts/Volume-4/Issue-2/Vol-4-issue-2-M-04.pdf">On The Negative Pell Equation y^2 = 72x^2 - 8</a>, International Journal of Emerging Technologies in Engineering Research (IJETER) Volume 4, Issue 2, February (2016).
%e a(5)=18 because A031396(5)=13, and the solution to x^2-13y^2=-1 with smallest possible x has x=18.
%p A130226 := proc(m)
%p local xm,x ,i,xmo,y2;
%p xm := [] ; # x^2-m*y^2=-1 (mod m) requires x in xm[]
%p for x from 0 to m-1 do
%p if modp(x^2,m) = modp(-1,m) then
%p xm := [op(xm),x] ;
%p end if;
%p end do:
%p for i from 0 do
%p for xmo in xm do
%p x := i*m+xmo ;
%p y2 := (x^2+1)/m ;
%p if issqr(y2) then
%p return x ;
%p end if;
%p end do:
%p end do:
%p end proc:
%p L := BFILETOLIST("b031396.txt") ;
%p n := 1:
%p for m in L do
%p printf("%d %d\n",n,A130226(m)) ;
%p n := n+1 ;
%p end do: # _R. J. Mathar_, Oct 19 2014
%t terms = 1000;
%t a031396 = Cases[Import["https://oeis.org/A031396/b031396.txt", "Table"], {_, _}][[;; terms, 2]];
%t sol[n_] := Solve[x > 0 && y > 0 && x^2 - n y^2 == -1, {x, y}, Integers];
%t a[1] = 0; a[n_] := a[n] = x /. sol[a031396[[n]]] /. C[1] -> 0 // First // Simplify // Quiet;
%t Table[Print[n, " ", a031396[[n]], " ", a[n]]; a[n], {n, 1, terms}] (* _Jean-François Alcover_, Apr 05 2020 *)
%Y Cf. A094048.
%K nonn
%O 1,3
%A _Colin Barker_, Aug 05 2007