Totient of a Prime Power

Also known as phi p^k · euler totient prime power · totient of a power

φ(pk)=pk−1(p−1)\varphi(p^k) = p^{k-1}(p - 1)

Units aren’t used in this calculation — every value is a plain number.

Worked example: φ(2⁵) = 16 — press Try an example to run it live, then adjust anything.

Enter your known values, leave one input blank, and solves for the missing one. Tap a variable’s symbol to see what it means, with a typical value.

Learning zone

Totient of a Prime Power explained

ppk−1φ

Counting the numbers below pkp^k that are coprime to it is easier than the general totient because there is only one prime to avoid. Of the pkp^k candidates, the ones sharing a factor are exactly the multiples of p, and there are pk−1p^{k-1} of those. Subtract: pk−pk−1=pk−1(p−1)p^k - p^{k-1} = p^{k-1}(p-1). For 25=322^5 = 32 that is 16×1=1616 \times 1 = 16, which is just the odd numbers — every odd number below 32 is coprime to it, and there are 16.

Set k = 1 and the formula reduces to p−1p - 1, the fact that everything below a prime is coprime to it. That special case is used constantly: it is why the multiplicative group mod p has p−1 elements, and therefore why Fermat's little theorem has the exponent it does.

Like the sum-of-divisors formula, this is a building block rather than a destination, because φ is multiplicative across coprime parts. φ(360)=φ(23)φ(32)φ(5)=4×6×4=96\varphi(360) = \varphi(2^3)\varphi(3^2)\varphi(5) = 4 \times 6 \times 4 = 96. Every factor there came from this one formula. And as always, p must actually be prime — the derivation counted "multiples of p" as the only numbers sharing a factor, which is false the moment p is composite.

Totient of a Prime Power formula

φ(pk)=pk−1(p−1)\varphi(p^k) = p^{k-1}(p - 1)
Where
  • pp= Prime
  • kk= Exponent
  • φ\varphi= Totient

Missing one of these? Work it out first, then come back