Monic irreducible polynomials

Here, we consider polynomials in 𝔽p[x]\mathbb{F}_p[x], that is, polynomials on xx whose coefficients are elements of 𝔽p={0,1,2,…,pβˆ’1}\mathbb{F}_p=\{0, 1, 2, \ldots, p-1\}, where pp is a prime number.

A polynomial is monic if the coefficient of its term with largest degree is 11. A polynomial is irreducible if it cannot be written as the product of two polynomials of smaller degree. Your task is to count the number of monic, irreducible polynomials of 𝔽p[x]\mathbb{F}_p[x] of a given degree dd.

Too difficult? Do not despair! The problem is not so hard, once you know that, in 𝔽p[x]\mathbb{F}_p[x], every monic polynomial can be written in a unique way as a factor of monic, irreducible polynomials. For instance, in 𝔽2[x]\mathbb{F}_2[x] there are 44 monic polynomials of degree 22 (in 𝔽2[x]\mathbb{F}_2[x], all polynomials are monic), but only one of them is irreducible: x2=xβ‹…xx2+1=(x+1)β‹…(x+1)x2+x=xβ‹…(x+1)x2+x+1=???x^2 = x\cdot x \qquad \enspace x^2+1 = (x+1)\cdot(x+1) \qquad \enspace x^2+x = x\cdot (x+1) \qquad \enspace x^2+x+1 = \enspace ???

In 𝔽2[x]\mathbb{F}_2[x], there are 88 monic polynomials of degree 33, but only two of them are irreducible: x3=xβ‹…xβ‹…xx3+x2=xβ‹…xβ‹…(x+1)x3+1=(x+1)β‹…(x2+x+1)x3+x2+1=???x3+x=xβ‹…(x+1)β‹…(x+1)x3+x2+x=xβ‹…(x2+x+1)x3+x+1=???x3+x2+x+1=(x+1)β‹…(x+1)β‹…(x+1)\begin{align*} x^3 &= x\cdot x \cdot x \enspace & \enspace x^3 + x^2 &= x\cdot x\cdot (x+1) \\ x^3+1 &= (x+1)\cdot(x^2+x+1) \enspace & \enspace x^3+x^2+1 &= \enspace ??? \\ x^3 + x &= x\cdot (x+1)\cdot (x+1) \enspace & \enspace x^3 + x^2 + x &= x\cdot (x^2+x+1) \\ x^3+x+1 &= \enspace ??? \enspace & \enspace x^3+x^2+x+1 &= (x+1)\cdot(x+1)\cdot(x+1) \end{align*}

Input

Input consists of several cases, each with a prime number 2≀p≀302 \le p \le 30 and an integer number 2≀d≀302 \le d \le 30. Additionally, we have pd<109p^d < 10^9.

Output

For every case, print the number of monic, irreducible polynomials in 𝔽p[x]\mathbb{F}_p[x] of degree dd.

Problem information

Author:Β Omer GimΓ©nez

Generation: 2026-01-25T11:19:43.984Z

© Jutge.org, 2006–2026.
https://jutge.org