ForHosting KIT · Math

Euler's totient φ(n)

Euler's totient of 36 is 12: that many numbers from 1 to 36 share no prime factor with 36. Enter any positive integer up to one trillion and get the exact count plus the prime factors behind it. Free in your browser.

  • Free
  • Runs in your browser
  • No sign-up
  • Your data stays on your device
Use it from WebAPIEmailTelegramApp soon
If you enter
N
36
You get
Phi
12
Coprime count
12

Euler's totient function φ(n) answers a basic counting question in number theory: among the integers from 1 through n, how many share no common prime factor with n? That count shows up in modular arithmetic, RSA key setup, cyclic group orders, and fraction reduced-form counts. This calculator takes a single positive integer n, builds its prime factorization by deterministic trial division, and evaluates the classical product formula so you get an exact φ(n) without floating-point guesswork or external services.

What Euler's totient measures and why it matters

Two integers are coprime when their greatest common divisor is one. Euler's totient φ(n) is simply the size of the set of residues in the range one through n that meet that condition. For a prime p the answer is p minus one, because every smaller positive integer is coprime to p.

For a prime power p to the k the answer is p to the k minus p to the k minus one, stripping multiples of p. For a general n the Chinese Remainder Theorem multiplies the local counts, which is why the closed product formula works.

Engineers meet φ(n) when they need the order of the multiplicative group of units modulo n, when they choose RSA public exponents that are coprime to φ of the modulus, when they count reduced fractions with denominator n, or when they size the cycle length of a linear congruential generator.

How this calculator evaluates φ(n) from prime factors

Call the capability with a positive integer field n. The implementation factors n with trial division: peel off factors of two, then odd candidates up to the square root, and finally any remaining prime cofactor. From that ordered list it applies the exact integer form of Euler's product: start with phi equal to n, and for every distinct prime p that divides n replace phi with floor(phi divided by p) times (p minus one).

Because each prime is processed once, higher powers do not require a separate geometric sum; the formula already folds the correct density.

Practical use, limits, pricing, and delivery

Use the browser tool when you want an immediate answer while studying, debugging a modular exponentiation step, or checking a textbook exercise. The accepted range is integers from one through one trillion, which keeps every intermediate product inside JavaScript safe-integer territory while still covering typical contest, classroom, and application sizes. Results are deterministic: the same n always yields the same phi and the same factor list.

There is no language model, no external factoring service, and no randomness, so the capability is safe to pin in automated tests.

Homework and contest verification

Students and graders can confirm φ(n) for arbitrary positive integers and inspect the prime factors the formula used, without relying on a local CAS.

Crypto and modular-arithmetic tutorials

Teaching materials that introduce RSA or multiplicative orders can compute φ of sample moduli on demand and show the factorization beside the totient.

What happens if n is less than 1?

Euler's totient is defined for positive integers only; zero and negatives are rejected and not charged.

How is φ(n) calculated?

n is factored by trial division, then the product formula φ(n) = n · Π (1 − 1/p) over distinct prime factors p is evaluated with exact integer steps.

Is the Euler totient calculator free?

The browser tool runs free on your device.

What is the largest n I can submit?

Integers from 1 through 1,000,000,000,000 (1e12) are accepted. Larger values are rejected so arithmetic stays within safe integer range.

What is the totient of 36?

It is 12. Since 36 = 2² × 3², multiply 36 by (1 − 1/2) and by (1 − 1/3): the result is 12, so twelve numbers from 1 to 36 are coprime to 36.

Everything on this page is available programmatically. This section is for teams who want to wire it into their own systems; everyone else can just use the tool above.

POSThttps://api.kit.forhosting.com/numth/euler-totient

Prefer to automate it? One authenticated POST creates the task; the result comes back by webhook or a signed link. The same capability also runs here on the web, by email and from Telegram — and soon from our app too.

curl -X POST https://api.kit.forhosting.com/numth/euler-totient \
  -H "Authorization: Bearer $KIT_KEY" \
  -H "Content-Type: application/json" \
  -d '{"n":36}'
{
  "n": 36
}
{
  "task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
  "type": "numth.euler_totient",
  "status": "queued",
  "_links": {
    "result": "/tasks/tsk_…/result"
  }
}

The API is asynchronous: the call returns a task_id immediately and the result arrives by webhook. Polling is capped at 1 req/s per task.

Per request$0.002

Published price — no tokens, no invented credits. A failed task is never charged.

max_n1000000000000
HTTPCodeMeaning
401unauthorizedMissing or invalid API key.
402insufficient_balanceYour balance doesn't cover the task price.
404unknown_typeThat task type doesn't exist.
429rate_limitedToo many requests. Use the webhook instead of polling.

What Euler's totient measures and why it matters

Having a single, deterministic endpoint that returns both the totient and the factors that produced it removes a common source of off-by-one mistakes in homework checkers, crypto tutorials, and integer pipelines that would otherwise reimplement factorization ad hoc.

How this calculator evaluates φ(n) from prime factors

The response includes n, phi, the factor list as prime and exponent pairs, and coprime_count as an explicit alias of phi for callers that want a self-describing field name. Inputs below one, non-integers, missing n, and values above the published upper bound are rejected as invalid_input and are never charged.

Practical use, limits, pricing, and delivery

Use the API when a script, CI job, or educational platform needs φ(n) for many values without shipping a factorization library. Each successful request is one billable item at $0.002; failed validation does not consume balance. Wire the endpoint into number-theory demos, crypto teaching sandboxes, or integer preprocessing steps where you already trust exact arithmetic more than approximate heuristics.

Automated number-theory pipelines

Scripts that enumerate reduced fractions, cycle lengths, or unit-group sizes can call a single deterministic item-priced endpoint instead of embedding factorization code.

How do I compute Euler's totient φ(n) with this API?

Send a JSON body with positive integer field n to the numth.euler_totient capability. The response returns phi, the ordered prime factorization, and coprime_count equal to phi.

Read the full KIT documentation →