After continued-fraction recovery in quantum order finding, an even candidate denominator can be used to try the displayed greatest common divisors. Return only a divisor strictly between one and . If is the true even multiplicative order with a nontrivial halfway power, success follows from factor extraction from an even modular order. A candidate that is not a period can occasionally still yield a factor; testing before the gcds therefore changes single-run success probabilities. The output-factor check guarantees correctness in either convention.
For coprime integers , the multiplicative order is the smallest positive exponent
It exists because multiplication by is an element of the finite group of units modulo an integer. For the example, the successive residues are
None of the first three is one, so the order is four.
The factor extraction from an even modular order uses the factorization . If the multiplicative order is even, put . Minimality of the multiplicative order excludes ; we also require . Thus is a nontrivial square root of one. Neither nor is divisible by all of . If either were coprime to , its inverse modulo , applied to , would make the other divisible by , a contradiction. Hence the greatest common divisors
are proper nontrivial factors. For odd , and have no common prime divisor of , so these two divisors are complementary. If the initial is not coprime to , a proper already supplies a factor without quantum order finding.
For and , and , which is neither nor . The factors are
The necessary conditions for this order-based reduction are a unit , even true multiplicative order, and .
The multiplicative order of modulo is the least positive integer such that
It exists because and are coprime integers.
Suppose that is even and
The minimality of also gives . Since
the factor extraction from an even modular order yields
as a nontrivial factor of ; equivalently one may also compute . Thus the required conditions are that be even and that .
Modulo ,
so . This order is even and
The factor extraction from an even modular order therefore gives
Thus
For an odd integer having at least two distinct prime divisors, choose a uniform unit . The Chinese remainder theorem for unit groups makes its odd-prime-power components independent cyclic groups. Failure of factor extraction from an even modular order requires all components to have equal 2-primary order exponents. For any component each possible exponent has probability at most , so conditioning on another component bounds failure by . Excluding the identity unit only improves the success proportion.