Tracing after the period is found on the quantum computer

For values of a that end up calling the quantum period finding subroutine, here is a trace of what happens after the period r = 4 is found:

  1. r = 4 is even, so we keep going!
  2. ar/2 = 24/2(mod 15) = 4 and 4 ≠ -1 (mod 35) = 14, so we keep going!
  3. We've found two factors of 15. They are gcd(ar/2 + 1, N) = gcd(24/2 + 1, 15) = 5 and gcd(ar/2 + 1, N) = gcd(24/2 - 1, 15) = 3.

Let's check our work: 3 * 5 = 15. We got it right! We can stop.