Skip to main content
. 2019 Aug 15;21(8):800. doi: 10.3390/e21080800
Algorithm 7: Shor [17]
  Proceed with the following steps to retrieve a factor of a composite number with highprobability.
  1. Pick at random an integer a±1 modulo N. If GCD(a,N) is a non-trivial factor of N, we

    have a solution.

  2. Otherwise generate, setup, and run the quantum Subroutine (also shown in

    Figure 42) to find a candidate for s/r.

  3. Use the continued fraction expansion to retrieve r (or a factor in r when s and r has a common factor).

  If r is even, one of GCD(ar/2±1,N) may be a non-trivial factor of N. This happens with highprobability.