Question: Write a function extract _ order ( meas , m , a , n ) given a measurement meas, number of qubits m , a
Write a function extractordermeas m a n given a measurement meas, number of qubits m a number a that is relatively prime to n The function return the order r if found using the successive approximation described above. If you cannot find the order, return None.
A modularexponentiation function is given to you.
def modularexponentiatea k n: # ak mod n
mu a
res
while k :
if k :
res res mu n
mu mu mu n
k k
return res
def extractordermeas m a n:
# your code here
for r in range n:
if modularexponentiatea r n meas:
return r
return None
r extractorder
assert r
r extractorder
assert r
r extractorder
assert r
r extractorder
assert r
r extractorder
assert r None
r extractorder
assert r
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
