Clear[Berlekamp]
\(Berlekamp[A_, x_, p_] := 
      Module[{n, lcoeff, a, reste, j, k, sol, β, b, 
          tab}, 
n = 
          Exponent[A, x]; 
lcoeff = 
          Coefficient[A, x, n]; 
a = 
          PolynomialMod[A\ PowerMod[lcoeff, \(-1\), p], 
            p]; 
reste = 
          Table[PolynomialMod[PolynomialRemainder[x\^\(j\ p\), a, x], p], {j, 
              0, n - 1}]; 
sol = 
          Solve[Union[
              Map[# == 0 &, 
                CoefficientList[
                  Sum[\(β\_k\) \((reste[\([k + 1]\)] - x\^k)\), {k, 0, 
                      n - 1}], x]], {Modulus == p}], 
            Table[β\_k, {k, 0, n - 1}]]; 

        b = PolynomialMod[
            Sum[\(\(β\_k\) x\^k /. 
                  sol[\([1]\)]\) /. β\_l_ -> 1, {k, 0, n - 1}], 
            p]; 
tab = 
          Table[PolynomialGCD[a, b - k, Modulus -> p], {k, 0, 
              p - 1}]; 
lcoeff\ Apply[Times, 
            tab]
]\)

Clear[AnzahlFaktoren]
AnzahlFaktoren[a_, x_, p_] := 
      Module[{n, reste, R, k, j, ns}, 
n = 
          Exponent[a, x]; 
reste = 
          Table[PolynomialMod[PolynomialRemainder[x^(p*k), a, x], p], {k, 
              0, n - 1}]; 
R = 
          Table[Coefficient[reste[[k]], x, j], {j, 0, 
              Length[reste] - 1}, {k, 
              Length[reste]}]; 
ns = 
          NullSpace[R - IdentityMatrix[Length[reste]], 
            Modulus -> p]; 
Length[
          ns]
]

AnzahlFaktoren[(x^6) + (x^5) + (x^4) + (x^3) + (x^2) + x + 1, x, 
      2]

Berlekamp[(x^6) + (x^5) + (x^4) + (x^3) + (x^2) + x + 1, x, 2]

AnzahlFaktoren[(x^6) + (x^5) + (x^4) + (x^3) + (x^2) + x + 1, x, 
      3]

AnzahlFaktoren[(x^10) + (x^9) + (x^7) + (x^3) + (x^2) + 1, x, 2]

faktoren = 
      Berlekamp[(x^10) + (x^9) + (x^7) + (x^3) + (x^2) + 1, x, 2]

AnzahlFaktoren[faktoren[[1]], x, 2]

AnzahlFaktoren[faktoren[[2]], x, 2]

Berlekamp[faktoren[[1]], x, 2]

Factor[(x^10) + (x^9) + (x^7) + (x^3) + (x^2) + 1, 
      Modulus -> 2]