| 1 | initial version |
You have a typo in your inner if-statement: x + j^n instead of x^n + j, so it always fails for degree reasons.
| 2 | No.2 Revision |
You have a typo in your inner if-statement: x + j^n instead of x^n + j, so it always fails for degree reasons.
You probably also want to avoid using the symbolic x and instead give the generator of your polynomial ring a proper name such as x, and name the image in the quotient something like xbar:
# We get the ring where we will check for primality
ZnX.<x> = IntegerModRing(n)[]
ZnX_mod_f.<xbar> = ZnX.quo(x^r-1)
for j in range(1, 2*log(n,2)*sqrt(r)+2):
if (xbar+j)^n != xbar^n+j:
print("The freshman dream test failed for j={}".format(j))
return False
Copyright Sage, 2010. Some rights reserved under creative commons license. Content on this site is licensed under a Creative Commons Attribution Share Alike 3.0 license.