14

Can we prove or disprove (perhaps under some standard hypothesis): $$\text{If for the first }\|n\|\text{ primes }p_i, \left(\dfrac{p_i} n\right)=+1,\text{ then }n\text{ is a square.}$$

where $\|n\|$ is the number of bits in $n$, $\left(\dfrac p n\right)$ is the Kronecker symbol, and $p_i$ is the $i^\text{th}$ prime, starting with $p_1=2$. By contraposition, the proposition can also be stated as: $$\text{If }n\in\mathbb N\text{ is not a square, then }\exists\,i\in\mathbb N^*\text{ with }2^{i-1}\le n\text{ and }\left(\dfrac{p_i}n\right)\ne+1$$

I don't know a counterexample for the stronger proposition with $2^i\le n$.

The proposition holds

  • For $n=0$, $n=1$, and more generally any $n$ that is a square.
  • For even $n>0$, since for these $\left(\frac 2 n\right)=0\ne+1$. Thus we can restrict to odd $n$ and use the Jacobi symbol rather than the Kronecker symbol.
  • If $n\bmod8\in\{3,5\}$, since for these $\left(\frac 2 n\right)=-1\ne+1$.

We can thus focus on $n\equiv\pm1\pmod8$, and turn to use of the Legendre symbol:

  • for $n\equiv+1\pmod8$ and odd $p_i$, we can change $\left(\dfrac{p_i} n\right)=+1$ to $\left(\dfrac n{p_i}\right)=+1$
  • for $n\equiv-1\pmod8$ and odd $p_i$, we can change $\left(\dfrac{p_i} n\right)=+1$ to $\left(\dfrac {-n}{p_i}\right)=+1$.

A closely related problem is studied by Richard F. Lukes, C. D. Patterson and Hugh C. Williams, Some results on pseudosquares, Math. Comp. 65 (1996), 361-372. The smallest $n$ for a given $i$ are the positive pseudosquares for $n\equiv+1\pmod8$, negative pseudosquares for $n\equiv-1\pmod8$. See A002189 and A045535.

Initial motivation: In some primality test algorithms we need the smallest $p_i$ with $\left(\dfrac{p_i}n\right)\ne+1$. The proposition tells that when finding none for $i\in\left[1,\|n\|\,\right]$, we can stop and declare there's no such $p_i$ since $n$ must be a square. If it was true, the proposition would avoid making an explicit square test.

Remark (not quite an argument): for a fixed small prime $p$ and a large random $n$, there is probability $\dfrac{p+1}{2p}>\dfrac 1 2$ that $\left(\dfrac p n\right)\ne+1$. The probabilities for small $p_i$ are only vanishingly correlated.


If we look at how many such tests we need, here are
◦ smallest non-square odd $n$ record-holders for high $\pi(p)$
◦ the smallest $p$ with $\left(\frac p n\right)\ne+1$
◦ the number $\|n\|$ of bits of $n$
◦ the index $\pi(p)$ per the prime counting function
◦ the margin $\Delta=\|n\|-\pi(p)$ there is for the proposition
◦ the kind of pseudosquare $n$: $-$ for $n\equiv-1\pmod8$, $+$ for $n\equiv+1\pmod8$
◦ the factorization of $n$ when composite

$$\begin{array}{|r|r|r|r|c|c|l|} \hline n&p&\!\|n\|\!&\pi(p)\!&\Delta&\text{kind}&\text{factors of }n\\ \hline 2&2&2&1&1&&\text{Prime}\\ 7&3&3&2&1&-&\text{Prime}\\ 23&5&5&3&2&-&\text{Prime}\\ 71&7&7&4&3&-&\text{Prime}\\ 311&11&9&5&4&-&\text{Prime}\\ 479&13&9&6&3&-&\text{Prime}\\ 1559&17&11&7&4&-&\text{Prime}\\ 5711&19&13&8&5&-&\text{Prime}\\ 10559&23&14&9&5&-&\text{Prime}\\ 18191&29&15&10&5&-&\text{Prime}\\ 31391&31&15&11&4&-&\text{Prime}\\ 118271&37&17&12&5&-&101\cdot1171\\ 366791&43&19&14&5&-&\text{Prime}\\ 2155919&59&22&17&5&-&59\cdot36541\\ 6077111&67&23&19&4&-&1039\cdot5849\\ 98538359&71&27&20&7&-&79\cdot1247321\\ 120293879&73&27&21&6&-&\text{Prime}\\ 131486759&83&27&23&4&-&\text{Prime}\\ 508095719&89&29&24&5&-&367\cdot547\cdot2531\\ 2570169839&113&32&30&2&-&439\cdot5854601\\ 196265095009&131&38&32&6&+&\text{Prime}\\ 513928659191&137&39&33&6&-&\text{Prime}\\ 844276851239&139&40&34&6&-&794239\cdot1063001\\ 1043702750999&149&40&35&5&-&389\cdot5689\cdot471619\\ 4306732833311&151&42&36&6&-&\text{Prime}\\ 8402847753431&157&43&37&6&-&\text{Prime}\\ 47375970146951&163&46&38&8&-&151717\cdot312265403\\ 52717232543951&167&46&39&7&-&223\cdot1747\cdot6863\cdot19717\\ 100535431791791&173&47&40&7&-&9873817\cdot10182023\\ 178936222537081&181&48&42&6&+&\text{Prime}\\ 493092541684679&193&49&44&5&-&4723\cdot104402401373\\ 1088144332169831&223&50&48&2&-&293\cdot464941\cdot7987687\\ 11641399247947921&227&54&49&5&+&\text{Prime}\\ 88163809868323439&229&57&50&7&-&96757\cdot911187923027\\ 196640248121928601&233&58&51&7&+&\text{Prime}\\ 423414931359807911&239&59&52&7&-&241\cdot1756908428878871\\ 695681268077667119&241&60&53&7&-&3413\cdot203832777051763\\ 1116971853972029831&257&60&55&5&-&1721\cdot869521\cdot746416591\\ 3546374752298322551&271&62&58&4&-&\text{Prime}\\ 10198100582046287689&277&64&59&5&+&277\cdot1091\cdot1151\cdot29318344777\\ \hline \end{array}$$

Values are extracted from Richard F. Lukes, A Very Fast Electronic Number Sieve, thesis presented to the University of Manitoba (1995), tables 6.22 (negative pseudosquares A045535) and 6.24 (positive pseudosquares A002189), and in the process of being independently verified. The terms to $\pi(p)=50$ also are in Nathan D. Bronson and Duncan A. Buell, Congruential Sieves on FPGA Computers, in Proceedings of Symposia in Applied Mathematics, Volume 48, 1994, 547-551.

Eric Naslund
  • 73,551
fgrieu
  • 1,828
  • 1
    Do you mean "If a $k$-bit integer $n$ is not a square"? And do you really need there to be exactly one prime $p$, or just at least one? – Misha Lavrov May 29 '22 at 04:58
  • 1
    You have your $p$ and $||n||$ headings the wrong way round. – Rosie F May 31 '22 at 07:07
  • 3
    This kind of problem in ANT is very hard in general; as far as I know, if even a probabilistic heuristic does not give the answer, then nothing within known Analytic NT will. – abacaba Jun 03 '22 at 14:55
  • 2
    Could you explain why you have the $p_i$'s in the top, and the $n$ in the bottom, of the quadratic symbol? The reason I ask is that having the $n$ in the top and the $p_i$'s in the bottom seems a more natural way to say "$n$ is a square modulo these primes"... Could you clarify, please? :) – paul garrett Jun 03 '22 at 20:57
  • @paul garrett: I now explain the original motivation in the question, and explain how to reduce the problem to the Legendre symbol $\left(\dfrac n{p_i}\right)$. That's an improvement, thanks for suggesting that. – fgrieu Jun 04 '22 at 22:14

1 Answers1

10

This is not known.

However, it may be provably false under the Generalized Riemann Hypothesis (GRH), depending on a constant calculated in a paper of Montgomery.

Least Quadratic Non-Residue

You are looking at the first $\log_2 n$ primes, the largest of which has size $\sim \log_2(n)\cdot \log\log(n)$, and asking if $\left(\frac{p}{n}\right)$ is $1$ for all of these primes, must $n$ be a square?

Equivalent Statement of Question: If $\left(\frac{p}{n}\right)=1$ for all primes $$p\leq (1+o_n(1)) \log_2 n \log\log n,$$ does it imply that $n$ is a square?

This problem is related to the least quadratic non-residue modulo $p$, which we denote by $n_p$.

If it is possible for the numbers $1,2,\dots,k$ to all be quadratic residues modulo $q$ for a sufficiently large $k>(1+\epsilon)\log_2(n)\cdot \log\log(n)$, this would disprove your proposition. This leads to the following claim:


Proposition:

For your proposition to be true, we must have $$n_q \leq \left(\frac{1}{\log 2}+o_q(1)\right)\log q \log \log q$$ for all primes $q$. If there exist $C>1$, and infinitely many primes such that $$n_q>\frac{C\log q \cdot \log \log q}{\log 2},$$ then your proposition is false.


Current Knowledge of $n_q$:

Under GRH, the following lower bound due to Montgomery 1971 $$ n_p = \Omega(\log p \log \log p)$$ and the following upper bound due to Ankeny 1952 $$n_p=O\left(\log p)^2\right).$$

If the constant in Montgomery's lower bound is large enough, it would disprove your conjecture under GRH. I am not particularly familiar with Montgomery's method, but based on some results in this paper of Granville and Soundararajan, I believe that it may be possible to show that the hypothesis of the claim above does hold for some $C>1$, and hence that your proposition is false under GRH.

Eric Naslund
  • 73,551