2015-11-18 06:14:39 +00:00
|
|
|
def expand_x_1(n):
|
|
|
|
|
# This version uses a generator and thus less computations
|
|
|
|
|
c =1
|
2019-09-12 10:33:56 -07:00
|
|
|
for i in range(n//2+1):
|
|
|
|
|
c = c*(n-i)//(i+1)
|
2015-11-18 06:14:39 +00:00
|
|
|
yield c
|
2015-02-20 09:02:09 -05:00
|
|
|
|
2015-11-18 06:14:39 +00:00
|
|
|
def aks(p):
|
|
|
|
|
if p==2:
|
|
|
|
|
return True
|
2015-02-20 09:02:09 -05:00
|
|
|
|
2015-11-18 06:14:39 +00:00
|
|
|
for i in expand_x_1(p):
|
|
|
|
|
if i % p:
|
|
|
|
|
# we stop without computing all possible solutions
|
|
|
|
|
return False
|
|
|
|
|
return True
|