cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

A130226 Smallest integer x satisfying the Pell equation x^2-k*y^2=-1 for the values of k given in A031396.

Original entry on oeis.org

0, 1, 2, 3, 18, 4, 5, 70, 6, 32, 7, 182, 99, 29718, 8, 1068, 43, 9, 378, 500, 5604, 10, 4005, 8890182, 776, 11, 682, 57, 1744, 12, 113582, 4832118, 13, 1118, 1111225770, 68, 1764132, 14, 3141, 251, 15, 1710, 23156, 71011068, 4443, 16, 6072, 82, 1407
Offset: 1

Views

Author

Colin Barker, Aug 05 2007

Keywords

Examples

			a(5)=18 because A031396(5)=13, and the solution to x^2-13y^2=-1 with smallest possible x has x=18.
		

Crossrefs

Cf. A094048.

Programs

  • Maple
    A130226 := proc(m)
        local xm,x ,i,xmo,y2;
        xm := [] ; # x^2-m*y^2=-1 (mod m) requires x in xm[]
        for x from 0 to m-1 do
            if modp(x^2,m) = modp(-1,m) then
                xm := [op(xm),x] ;
            end if;
        end do:
        for i from 0 do
            for xmo in xm do
                x := i*m+xmo ;
                y2 := (x^2+1)/m ;
                if issqr(y2) then
                    return x ;
                end if;
            end do:
        end do:
    end proc:
    L := BFILETOLIST("b031396.txt") ;
    n := 1:
    for m in L do
        printf("%d %d\n",n,A130226(m)) ;
        n := n+1 ;
    end do: # R. J. Mathar, Oct 19 2014
  • Mathematica
    terms = 1000;
    a031396 = Cases[Import["https://oeis.org/A031396/b031396.txt", "Table"], {, }][[;; terms, 2]];
    sol[n_] := Solve[x > 0 && y > 0 && x^2 - n y^2 == -1, {x, y}, Integers];
    a[1] = 0; a[n_] := a[n] = x /. sol[a031396[[n]]] /. C[1] -> 0 // First // Simplify // Quiet;
    Table[Print[n, " ", a031396[[n]], " ", a[n]]; a[n], {n, 1, terms}] (* Jean-François Alcover, Apr 05 2020 *)