shor大数分解算法
Classical part[edit]
- Pick a random number a < N.
- Compute gcd(a, N). This may be done using the Euclidean algorithm.
- If gcd(a, N) ≠ 1, then this number is a nontrivial factor of N, so we are done.
- Otherwise, use the period-finding subroutine (below) to find r, the period of the following function:
- If r is odd, go back to step 1.
- If a r /2 −1 (mod N), go back to step 1.
- gcd(ar/2 + 1, N) and gcd(ar/2 - 1, N) are both nontrivial factors of N. We are done.
For example: , , where , and .
参考文献:
[1] Shor P W. Polynomial-Time Algorithms for Prime Factorization and Discrete Logarithms on a Quantum Computer[M]. Society for Industrial and Applied Mathematics, 1997.