OFFSET
1,4
COMMENTS
This is essentially a part of Shor's algorithm.
While in Shor's algorithm the key step is to determine the period (or order) of x^r (mod n), based on finding the smallest even multiplicative order number r such that x^r = 1 (mod n) for a random x in order to factor a number n efficiently, in this algorithm we find such r for the least x coprime to n.
If this r is not even, it is discarded and the next number x is tried.
While in Shor's quantum algorithm the period search function runs in polynomial time, its classical counterpart runs in non-polynomial time.
Also a(n) is a divisor of the Euler's totient of n (A000010).
LINKS
Robert Israel, Table of n, a(n) for n = 1..10000
Wikipedia, Shor's algorithm.
FORMULA
a(n) = gcd(a(n), A000010(n)) for n >= 3.
MAPLE
f:= proc(n) local x, r;
for x from 2 to n do
if igcd(x, n) <> 1 then next fi;
r:= numtheory:-order(x, n);
if r::even and r < n-1 then return r fi
od;
0
end proc:
map(f, [$1..100]); # Robert Israel, Nov 14 2024
PROG
(Python)
from sympy import gcd
from sympy.ntheory.residue_ntheory import n_order
def a(n):
for x in range(2, n):
if gcd(x, n) == 1:
r = n_order(x, n)
if r & 1 == 0 and r < n-1:
return r
return 0
print([a(n) for n in range(1, 77)])
CROSSREFS
KEYWORD
nonn,look
AUTHOR
Darío Clavijo, Oct 14 2024
STATUS
approved