Euler Totient and Co-prime Calculator


Count positive integers relatively prime to N and find their sum. Useful for elementary number theory and modular-arithmetic exercises.

Use consistent units. Enter numbers without thousands separators. Invalid input clears all results.

请输入数值:

Whole number from 1 to 1,000,000,000.

结果:

Inputs and results

Choose the matching mode, then read each field label and note. Results use the same length, time, currency or quantity units as the inputs unless a label says otherwise. A negative change means a decrease.

Formula

phi(N) = N × product of (1 - 1/p) over distinct prime divisors p. For N > 1, the sum of positive co-primes below N is N phi(N)/2, by pairing k with N-k. By convention phi(1)=1, but there are no positive integers strictly below 1.

Worked example

For N = 12, prime divisors are 2 and 3. phi(12) = 12 × 1/2 × 2/3 = 4. The co-primes below 12 are 1, 5, 7, 11 and their sum is 24.

Limits and edge cases

N must be an integer from 1 to 1e9. The sum is returned as an exact integer string using BigInt. Negative values, zero and decimals are rejected. This tool is not intended for cryptographic-size integers. Decimal calculations use floating-point arithmetic; displayed values are rounded to 12 significant digits. This is an educational tool, not a guarantee about investments or physical systems.

FAQ

Why are phi(1) and the below-1 count different?

phi(1)=1 is the standard convention for integers up to 1. The strictly-below-1 set is empty.

What is phi(p) for a prime p?

It is p-1, because each positive smaller integer is co-prime to p.

Formula reference

Background mathematics. Explanation and examples on this page are independently written.