Skip to main content
2 of 7
added 563 characters in body
GH from MO
  • 105.4k
  • 8
  • 293
  • 398

The correct statement is given by the deterministic Miller-Rabin test coupled with an estimate of Bach under GRH.

Theorem. Assume GRH. Let $n$ be an odd integer, and write $n-1$ as $2^st$ with $t$ odd. Then $n$ is composite if and only if there is $1<b<2\log^2 n$ coprime with $n$ such that $b^t\not\equiv 1\pmod{n}$ and $b^{2^r t}\not\equiv -1\pmod{n}$ for some $0\leq r<s$.

For more details see Section V.1 in Koblitz: A course in number theory and cryptography (2nd edition, GTM 114, Springer, 1994).

Added. The OP wanted more specific answers to his questions Q1 and Q2. Here they are:

Q1: The quoted paragraph without the parentheses gives a complete proof for the square-free test, so Granville's paper can be taken as a reference (although I am sure Lenstra wrote this down earlier in some form). The part in parentheses is false, so there is no reference for it. A corrected version for this part is given above, and a reference for it is Koblitz's book (or the original papers by Miller, Rabin, Bach).

Q2: There is nothing wrong with the quoted counterexample. It is a genuine counterexample to the part in parentheses, which shows in particular that the part in parentheses is false.

GH from MO
  • 105.4k
  • 8
  • 293
  • 398