for i in range(p):
    ex.append(ex[-1] * -(p - i) / (i + 1))
return ex[::-1]

def aks_test(p):
    if p < 2:
        return False
ex = expand_x_1(p)
ex[0] += 1
return not any(mult % p for mult in ex[0:-1])
print('# p: (x-1)^p for small p')
AKS Primes algorithm in Python