quantum.shor_algorithm

Attributes

shor

Classes

Shor

Module Contents

class quantum.shor_algorithm.Shor
period_find(num: int, number: int) int

Find the period of a^x mod N.

>>> shor = Shor()
>>> shor.period_find(2, 15)
4
>>> shor.period_find(3, 7)
6
shor_algorithm(number: int) tuple[int, int]

Run Shor’s algorithm to factor a number. >>> shor = Shor() >>> random.seed(0) >>> factors = shor.shor_algorithm(15) >>> isinstance(factors, tuple) and len(factors) == 2 True >>> factors (3, 5)

quantum.shor_algorithm.shor