1000th smallest prime

I have got a surprise for you

In honor of 7919 being the 1000th smallest prime number, we want to find the number of pairs of consecutive (positive) quadratic residues with respect to 7919 that are less than 7919.

Surprise : After solving the problem compare 7919 with your answer. Isn't is amazing?


The answer is 1979.

This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try refreshing the page, (b) enabling javascript if it is disabled on your browser and, finally, (c) loading the non-javascript version of this page . We're sorry about the hassle.

2 solutions

Patrick Corn
May 10, 2019

The number of consecutive positive quadratic residues mod p p that are less than p p is p 5 4 \frac{p-5}4 if p 1 ( m o d 4 ) p \equiv 1 \pmod 4 and p 3 4 \frac{p-3}4 if p 3 ( m o d 4 ) . p \equiv 3 \pmod 4. So the answer is 7919 3 4 = 1979 . \frac{7919-3}4 = \fbox{1979}.

To prove the general statement about quadratic residues, let C C be the number of consecutive quadratic residues. Then consider x = 1 p 1 ( ( x p ) + 1 ) ( ( x + 1 p ) + 1 ) . \sum_{x=1}^{p-1} \left( \left( \frac{x}{p} \right) + 1 \right) \left( \left( \frac{x+1}{p} \right) + 1 \right). Here ( ) \left( \frac{\cdot}{\cdot} \right) is the Legendre symbol .

When x x and x + 1 x+1 are both quadratic residues, we get 4. 4. When one of them is a nonresidue, we get 0. 0. There is one more case: when x = p 1 , x=p-1, we get ( 1 p ) + 1. \left( \frac{-1}{p} \right) + 1. So the conclusion is that 4 C + 1 + ( 1 p ) = x = 1 p 1 ( ( x p ) + 1 ) ( ( x + 1 p ) + 1 ) . 4C + 1 + \left( \frac{-1}{p} \right) = \sum_{x=1}^{p-1} \left( \left( \frac{x}{p} \right) + 1 \right) \left( \left( \frac{x+1}{p} \right) + 1 \right).

Expanding the sum on the right gives 4 C + 1 + ( 1 p ) = x = 1 p 1 ( x p ) ( x + 1 p ) + x = 1 p 1 ( x p ) + x = 1 p 1 ( x + 1 p ) + ( p 1 ) . 4C + 1 + \left( \frac{-1}{p} \right) = \sum_{x=1}^{p-1} \left( \frac{x}{p} \right) \left( \frac{x+1}{p} \right) + \sum_{x=1}^{p-1} \left( \frac{x}{p} \right) + \sum_{x=1}^{p-1} \left( \frac{x+1}{p} \right) + (p-1). The second term is 0 , 0, because there are p 1 2 \frac{p-1}2 residues and p 1 2 \frac{p-1}2 nonresidues. The third term is 1 , -1, because it is the same as the second term, except that it replaces ( 1 p ) = 1 \left(\frac1{p} \right) = 1 with ( p p ) = 0. \left(\frac{p}{p} \right) = 0. Bringing everything to the left side gives 4 C + 3 p + ( 1 p ) = x = 1 p 1 ( x p ) ( x + 1 p ) = x = 1 p 1 ( x 2 + x p ) . 4C + 3 - p + \left( \frac{-1}{p} \right) = \sum_{x=1}^{p-1} \left( \frac{x}{p} \right) \left( \frac{x+1}{p} \right) = \sum_{x=1}^{p-1} \left( \frac{x^2+x}{p} \right). But ( x 2 + x p ) = ( x 2 p ) ( 1 + x 1 p ) = ( 1 + x 1 p ) . \left(\frac{x^2+x}{p}\right) = \left(\frac{x^2}{p}\right)\left(\frac{1+x^{-1}}{p}\right) = \left(\frac{1+x^{-1}}{p}\right). As x x ranges from 1 1 to p 1 , p-1, so does x 1 , x^{-1}, so y = 1 + x 1 y=1+x^{-1} ranges from 2 2 to p . p. We get 4 C + 3 p + ( 1 p ) = x = 1 p 1 ( 1 + x 1 p ) = y = 2 p ( y p ) = 1. 4C + 3 - p + \left( \frac{-1}{p} \right) = \sum_{x=1}^{p-1} \left( \frac{1+x^{-1}}{p} \right) = \sum_{y=2}^p \left( \frac{y}{p} \right) = -1. So 4 C = p 4 ( 1 p ) , 4C = p-4-\left( \frac{-1}{p} \right), which gives the result we had claimed.

K T
Aug 9, 2019

This code uses a boolean array, in which it sets the quadratic residue entries to True. It then counts the number of consecutive pairs of positive quadratic residues. It outputs 1979.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
import numpy

p=7919;
bools = numpy.zeros(p);
for x in range(0, p):
    bools[(x**2)%p]=True; 
count=0;
for x in range(1, p-1):
    if bools[x] and bools[x+1]:
        count+=1;
print(count);

0 pending reports

×

Problem Loading...

Note Loading...

Set Loading...