[seqfan] Definition of A166980, quadratic residues

Richard Mathar mathar at strw.leidenuniv.nl
Mon Nov 2 12:54:35 CET 2009


I do not understand the construction of A166980
http://research.att.com/~njas/sequences/A166980
The definition, as I see it, is that "a(n) is the smallest prime q which has a
quadratic residue prime(n)."
At n=4 with prime(4)=7, we are searching for the smallest prime
with quadratic residue of 7, which is 2, because 7 = 3^2 (mod 2).
So there is something missing in the definition which I do not understand.

The equivalent maple program

A166980 := proc(n)
        local p,q,i ;
        p := ithprime(n) ;
        for i from 1 do
                q := ithprime(i) ;
                if numtheory[legendre](p,q) = 1 then
                        return q;
                end if;
        od:
end proc;
seq(A166980(n),n=1..80) ;


generates the sequence 
7, 11, 11, 2, 5, 3, 2, 3, 2, 5, 2, 3, 2, 3, 2, 7, 5, 3, 3, 2, 2, 2, 17, 2, 2,
    5, 2, 7, 3, 2, 2, 5, 2, 3, 5, 2, 3, 3, 2, 13, 5, 3, 2, 2, 7, 2, 3, 2, 29,
    3, 2, 2, 2, 5, 2, 2, 5, 2, 3, 2, 3, 17, 3, 2, 2, 7, 3, 2, 7, 3, 2, 2, 2, 3,
    3, 2, 5, 3, 2, 2

which differs from the current A166980 .

When the definition is changed to "a(n) is the smallest prime > prime(n) with
quadratic residue prime(n)"
we have

A166980 := proc(n)
        local p,q,i ;
        p := ithprime(n) ;
        for i from 1 do
                q := ithprime(i) ;
                if numtheory[legendre](p,q) = 1 and q>p then
                        return q;
                end if;
        od:
end proc;
seq(A166980(n),n=1..80) ;

and get

7, 11, 11, 19, 19, 17, 19, 31, 29, 53, 41, 41, 43, 53, 53, 59, 67, 73, 73, 73,
    79, 89, 103, 97, 101, 107, 127, 127, 113, 127, 139, 139, 139, 151, 173,
    163, 167, 173, 173, 179, 193, 193, 193, 197, 223, 211, 223, 241, 251, 233,
    241, 241, 251, 283, 283, 269, 283, 281, 281, 283, 293, 307, 313, 313, 317,
    353, 337, 349, 367, 353, 383, 389, 379, 383, 401, 389, 409, 401, 409, 419
which also differs from the current A166980.


Richard Mathar




More information about the SeqFan mailing list