Ask Your Question

Revision history [back]

Generate all the monic polynomials up to degree n with coefficients in Zp(p prime number) field and find all the irriducible polynomials

def POLYNOMIAL_OBTAINED_BY_RECURSION(p,n): R=Zmod(p) Z.<x>=PolynomialRing(R) All=[] if n==1: h=[] for i in range(0,p): pol=x+i h.append(pol) return(pol) All.append(Set(h)) else : h=[] for i in range(0,p): Pol=POLYNOMIAL_OBTAINED_BY_RECURSION(p,n-1)+i*(x^(n-1))+x^n h.append(Pol) return(Pol) All.append(Set(h)) return(All)

def MYSIEVE(n,All) for d in range(1,floor(n/2)+1): for j in range(d+1,n+1): for polinomio1 in All[j]: for polinomio2 in All[d]: if polinomio1%polinomio2==0: k={polinomio1} All[j].difference(k) return(All)

def project(p,n): if not(is_prime(p)): print('p is not prime',p) R=Zmod(p) Z.<x>=PolynomialRing(R) All=[] All=POLYNOMIAL_OBTAINED_BY_RECURSION(p,n) All=MYSIEVE(n,All) return(All)

Generate all the monic polynomials up to degree n with coefficients in Zp(p prime number) field and find all the irriducible polynomials

def POLYNOMIAL_OBTAINED_BY_RECURSION(p,n): R=Zmod(p) Z.<x>=PolynomialRing(R) All=[] if n==1: h=[] for i in range(0,p): pol=x+i h.append(pol) return(pol) All.append(Set(h)) else : h=[] for i in range(0,p): Pol=POLYNOMIAL_OBTAINED_BY_RECURSION(p,n-1)+i*(x^(n-1))+x^n h.append(Pol) return(Pol) All.append(Set(h)) return(All)

def MYSIEVE(n,All)
    for d in range(1,floor(n/2)+1):
        for j in range(d+1,n+1):
            for polinomio1 in All[j]:
                for polinomio2 in All[d]:
                    if polinomio1%polinomio2==0:
                        k={polinomio1}
                        All[j].difference(k)
    return(All)

return(All) def project(p,n): if not(is_prime(p)): print('p is not prime',p) R=Zmod(p) Z.<x>=PolynomialRing(R) All=[] All=POLYNOMIAL_OBTAINED_BY_RECURSION(p,n) All=MYSIEVE(n,All) return(All)

return(All)

Generate all the monic polynomials up to degree n with coefficients in Zp(p prime number) field and find all the irriducible polynomials

My code.

def POLYNOMIAL_OBTAINED_BY_RECURSION(p,n):
     R=Zmod(p)
     Z.<x>=PolynomialRing(R)
     All=[]
     if n==1:
         h=[]
         for i in range(0,p):
             pol=x+i
             h.append(pol)
             return(pol)
         All.append(Set(h))
     else :
         h=[]
         for i in range(0,p):
             Pol=POLYNOMIAL_OBTAINED_BY_RECURSION(p,n-1)+i*(x^(n-1))+x^n
             h.append(Pol)
             return(Pol)
         All.append(Set(h))
        return(All)

return(All)

def MYSIEVE(n,All)
    for d in range(1,floor(n/2)+1):
        for j in range(d+1,n+1):
            for polinomio1 in All[j]:
                for polinomio2 in All[d]:
                    if polinomio1%polinomio2==0:
                        k={polinomio1}
                        All[j].difference(k)
    return(All)

def project(p,n):
    if not(is_prime(p)):
        print('p is not prime',p)
    R=Zmod(p)
    Z.<x>=PolynomialRing(R)
    All=[]
    All=POLYNOMIAL_OBTAINED_BY_RECURSION(p,n)
    All=MYSIEVE(n,All)
    return(All)