What Euler's totient φ(n) means and how to compute it
Euler's totient φ(n) counts how many integers from 1 to n are coprime to n, meaning their only common divisor with n is 1. Take 10: the values 1, 3, 7 and 9 qualify, so φ(10)=4. For n = 1 the only candidate is 1 itself and gcd(1,1)=1, which is why φ(1)=1. A prime p excludes only p itself, so φ(p)=p−1, and a prime test row appears alongside the result when that applies.
The computation runs through the prime factorization. Once the distinct prime factors are known, φ(n) = n × (1−1/p₁) × (1−1/p₂) × … gives the answer. Evaluating that product in floating point is where accuracy slips, because factors like 1/3 have no exact decimal form. This calculator therefore divides by each prime before multiplying, so every intermediate value stays an exact integer. For 360 the chain runs 360÷2×1=180, then 180÷3×2=120, then 120÷5×4=96, giving φ(360)=96.
Those steps are printed as they happen, so you can see how the answer was built, and the ratio φ(n) ÷ n is listed as well. For n up to 100 every coprime value is listed so you can count them yourself and confirm the total. Factoring only tests divisors up to the square root of n, which keeps inputs up to one trillion fast. Zero, negative values and decimals have no totient and are not supported.
Frequently Asked Questions
It counts how many integers from 1 to n share no factor with n other than 1. For 10 those are 1, 3, 7 and 9, so φ(10)=4.
The only integer from 1 to 1 is 1 itself, and gcd(1,1)=1, so exactly one value qualifies.
A prime p shares a factor only with itself, so every integer from 1 to p except p qualifies and φ(p)=p−1. A prime test row appears with the result in that case.