qit.examples.shor_factorization

qit.examples.shor_factorization(N=9, cheat=False)

Shor’s factorization algorithm demo.

Simulates Shor’s factorization algorithm.

Parameters
  • N (int) – integer to factorize

  • cheat (bool) – If False, simulates the full algorithm. Otherwise avoids the quantum part.

Returns

a factor of N

Return type

int

NOTE: This is a very computationally intensive quantum algorithm to simulate classically, and probably will not run for any nontrivial value of N (unless you choose to cheat, in which case instead of simulating the quantum part (implemented in find_order) we use a more efficient classical algorithm for the order-finding).

See [3], [4] chapter 5.3.