Is there any way to predict the largest number of consecutive quadratic or cubic residues modulo prime $p$? 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$).
 A: A useful exact formula is unlikely; it might even be unknown
how to compute this number in time much less than $p$.
But we can still give heuristic estimates and compare them with known theorems.
Typically we expect $\log_2 p$ for consecutive quadratic residues,
and $\log_3 p$ for consecutive cubic residues, because
the number of stretches of $n$ consecutive quadratic (cubic) residues
should be about $p/2^n$ (resp. $p/3^n$) on average.  For example,
if $p = 10^6 + 7$ (the first seven-digit prime) then the quadratic-residue
counts for $n \leq 20$ are
500001, 250000, 125000, 62536, 31286, 15606, 7804, 3908, 1951, 948, 
481, 249, 126, 64, 36, 20, 11, 4, 2, 0

The two survivors for $n=19$ start at $295213$ and $860213$.
Using the (Hasse-)Weil bound (1949), we can show that the actual counts
differ from $p/2^n$ and $p/3^n$ by $O(n \sqrt p)$, so we're always
guaranteed a stretch of length at least $(\frac12 - o(1)) \log_2 p$
or $(\frac12 - o(1)) \log_3 p$.  To apply the Weil bound for quadratic residues
(the cubic case is similar), let $\chi$ be the quadratic character $\bmod p$,
and write the number of $a \bmod p$ such that $\chi(a+i) = 1$ for each
$i=1,2,\ldots,n$ as
$$
  2^{-n} \sum_{a \bmod p} \prod_{i=1}^n \bigl(1 + \chi(a+i) \bigr)
$$
up to an error of at most $n$ from the $n$ values of $a$ such that
some $a+i = 0$.  Now expand the product over $i$ into $2^n$ terms;
the term $1$ sums to $p$, and each of the remaining terms
has absolute value less than $n \sqrt p$ by Weil.
Exact formulas are known only for $n \leq 3$.
For example, the number of consecutive triples of quadratic residues mod $p$
is $\lfloor p/8\rfloor$ if $p \equiv 3 \bmod 4$; if $p \equiv 1 \bmod 4$
there's a more complicated formula involving the Fermat decomposition of $p$
as a sum of two squares.
Upper bounds are harder.  Varying $p$ gives us about $x^2 / (2 \log x)$
chances with $p \leq x$, which roughly doubles the maximal expected lengths to
about $2 \log_2 x$ and $2 \log_3 x$.  We might be able to squeeze out
a $\log \log x$ factor by looking at the first $p$ at which
each of the first $n$ primes $2,3,5,\ldots$ is a quadratic (cubic) residue;
if this $p$ is typically proportional to $n 2^n$ (resp. $n 3^n$)
then we get consecutive quadratic (cubic) residues up to the
$n$-th prime, which is about $n \log n$.  Note that this trick
is not applicable to "quadratic (cubic) non-residues".
By the Burgess bounds (1963) on $\sum_{i=1}^n \chi(a+i)$,
for each $\epsilon > 0$ there's an effective constant $C_\epsilon$
such that the number of consecutive quadratic or cubic residues $\bmod p$
is $< C_\epsilon p^{1/4 + \epsilon}$.  This is surely very far from sharp
for large $p$, though it's still more than enough to refute
the guess of $\sim \frac12 \sqrt p$ (Bennett 1926) reported by
Gerry Myerson.
