Is there any way to predict the largest number of consecutive quadratic or cubic residues modulo prime $p$

cubic-reciprocitymodular arithmeticmodular-nth-rootsnumber theoryquadratic-residues

We all know that $a$ is a quadratic residue modulo $p$ if and only if $a^{(p-1)/2} \equiv 1 \pmod p$,

also $a$ is a cubic residue modulo $p$ if and only if $a^{(p-1)/3} \equiv 1 \pmod p$.

Now, for a given prime $p$:

(1) is there any way to predict the largest number of consecutive quadratic residues modulo $p$?

for example, the largest number of consecutive quadratic residues modulo $103$ is 7, since $\{13, 14, 15, 16, 17, 18, 19\}$ are quadratic residue modulo $103$.

(2) is there any way to predict the largest number of consecutive cubic residues modulo $p$?

for example, the largest number of consecutive cubic residues modulo $73$ is 4, since $\{7, 8, 9, 10\}$ or $\{63, 64, 65, 66\}$ are cubic residues modulo $73$

(3) can I predict (or give an upper bond to) the number of quadratic residues sequences of the length $n$?

for example, there are $12$ quadratic residues sequences of the length $3$ (modulo $103$).

(4) can I predict (or give an upper bond to) the number of cubic residues sequences of the length $n$?

for example, there are $17$ cubic residues sequences of the length $4$ (modulo $997$).

Best Answer

At https://oeis.org/A002307 there is a link https://www.ams.org/journals/bull/1926-32-03/S0002-9904-1926-04211-7/ to A. A. Bennett, Consecutive quadratic residues, Bull. Amer. Math. Soc. 32 (1926), 283-284, DOI: https://doi.org/10.1090/S0002-9904-1926-04211-7.

The introduction states,

"I have succeeded in proving that for each prime greater than $193$ there is at least one sequence of five consecutive positive reduced quadratic residues. The proof entails the examination of many hundred linear forms which together include all primes. Since the method would prove excessively laborious for even the next case, that of six consecutive quadratic residues, the computational details seem hardly to warrant the space required for their complete publication."

Bennett further writes that, looking at the primes up to $317$, the length of the longest run of quadratic residues modulo $p$ "is fairly closely approximated by" $(1/2)\sqrt{p+20\log_{10}p}$.

Personally, I wouldn't put too much confidence in any estimate backed up by the primes up to $317$.

The oeis link also attributes to Jonathan Sondow a claim that the length is bounded by $2\sqrt p$, but no proof is given.

https://oeis.org/A002307/b002307.txt tabulates the length of the longest run of residues for the first $10,000$ primes.

https://oeis.org/A097159 tabulates "Smallest prime $p$ such that there are $n$ consecutive quadratic residues mod $p$" up to $n=33$; here it is:

$2, 7, 11, 19, 43, 67, 83, 131, 283, 277, 467, 479, 1907, 1607, 2543, 1559, 5443, 5711, 6389, 14969, 25703, 10559, 20747, 52057, 136223, 90313, 162263, 18191, 167107, 31391, 376589, 607153, 671947.$

So, e.g., the smallest prime with two consecutive residues is $7$, the smallest with three consecutive is $11$, ..., the smallest with $33$ consecutive is $671947$. Note the list is not strictly increasing; $283$ has nine consecutive, but the smaller prime $277$ has ten.

There is also a comment, $a(35)=298483$, $a(36)=422231$, $a(40)=701399$ and $a(42)=366791$.

Also relevant is https://oeis.org/A097160, "Greatest prime $p$ such that there are $n$, but not $n+1$, consecutive quadratic residues mod $p$, or $-1$ if no such prime exists." This list is very short: $5, 17, 53, 193, 457, 2153$. It is conjectured that it continues $4481, 9857, 25793, 60961, 132113, 324673$. A proof is given that $17$ is the largest prime with two, but not three, consecutive residues. The proof is too long to be included here.

There is a reference to Alfred Brauer, Ueber Sequenzen von Potenzresten, S.-B. Deutsch. Akad. Wiss. Berlin 1928, 9-16, and a link to D. H. Lehmer and Emma Lehmer, On Runs of Residues, Proc. Amer. Math. Soc, Vol. 13, No. 1 (Feb., 1962), pp. 102-106. The link is https://www.ams.org/journals/proc/1962-013-01/S0002-9939-1962-0138582-6/home.html

There is also https://oeis.org/A097161 "Number of primes modulo which the largest number of consecutive quadratic residues is $n$," but some of the entries in this list may be unproved.

Concerning higher power residues, there is https://oeis.org/A000236 "Maximum $m$ such that there are no two adjacent elements belonging to the same $n$-th power residue class modulo some prime $p$ in the sequence $1,2,...,m$" I don't know whether there are other oeis entries for higher power residues.