Totatives list calculator
A totative of n is a positive integer no greater than n that shares no factor with n except 1.
Run — free
This calculator produces the complete ordered list rather than only reporting Euler's totient count. Enter a positive integer to receive the original value, the number of matching integers, and the totatives themselves. It is useful for checking modular arithmetic exercises, exploring reduced residue systems, and seeing exactly which values contribute to the Euler totient function.
What the totatives list represents
The totatives of n are precisely the integers from 1 through n whose greatest common divisor with n equals 1. Saying that two numbers have greatest common divisor 1 is the same as saying they are coprime or relatively prime. For example, a candidate is excluded if it shares any prime factor with n, even when the candidate does not divide n. The returned array is sorted in increasing order because candidates are tested from 1 upward. The value 1 always appears, since it is coprime to every positive integer. The endpoint n normally does not appear because gcd(n, n) equals n; the special case is n = 1, for which the list is [1]. The accompanying count equals the length of the list and therefore equals Euler's totient function phi(n). This capability exposes the actual members, while a totient-only calculator is preferable when you need only the count for a very large integer. The distinction matters in modular arithmetic, where the members themselves form the reduced residue system modulo n.
How the calculation works
The calculator validates n before doing any arithmetic. It accepts a whole number or an integer written as a plain decimal string, rejects fractions and nonnumeric values, and reports an input error when n is below 1. It also enforces the published upper bound so that producing a potentially large JSON array remains predictable in both the browser and the API. After validation, the algorithm considers every integer from 1 to n. For each candidate it applies the Euclidean algorithm: repeatedly replace the larger pair with the divisor and remainder until the remainder becomes zero. The last nonzero divisor is the greatest common divisor. A candidate enters the result only when that divisor is 1. This procedure is exact integer arithmetic; it uses no approximation, factor database, network request, random choice, or clock. Consequently the same input always yields the same ordered output. The count is derived from the completed array rather than calculated separately, preventing disagreement between the displayed list and its reported size.
Using the result correctly
Use the list when your next step depends on the individual residue classes rather than merely their quantity. In elementary number theory, it provides a direct way to verify which numbers are invertible modulo n: every listed value has a multiplicative inverse modulo n, and every omitted value does not. In cryptography lessons, the output can help demonstrate why a multiplier must be coprime to a modulus, though it is an educational arithmetic result rather than a key-generation system. You can also compare the returned count with a hand calculation of Euler's totient formula to check factorization work. Remember that coprimality is a relationship, not a claim that each listed number is prime. Composite values may appear whenever they share no prime factor with n. For instance, a composite candidate can be a totative of a prime modulus. For automated use, read the totatives array directly and treat count as a convenient summary. If you only need to know whether one particular pair is coprime, a pairwise coprime checker avoids constructing the full list.
What you can do with it
Build a reduced residue system
Generate the complete increasing set of residue representatives that are invertible modulo n.
Check number theory exercises
Compare a hand-written totatives list and totient count with a deterministic computed result.
Explore modular inverses
Identify every value in the standard range that can have a multiplicative inverse modulo n.
FAQ
What is a totative?
A totative of n is a positive integer at most n whose greatest common divisor with n is 1.
Is the count Euler's totient function?
Yes. The number of values in the returned totatives array is phi(n), Euler's totient function.
Why is n usually absent from its own list?
Because gcd(n, n) is n, not 1. The exception is n = 1, whose totatives list is [1].
Must every totative be prime?
No. A totative may be composite; it only needs to share no prime factor with n.
What does a request cost?
The API price is $0.002 per request. The browser version runs locally without an API charge.
For developers — API access
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.
API endpoint
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.
Call it from your stack
curl -X POST https://api.kit.forhosting.com/numth/totatives-list \
-H "Authorization: Bearer $KIT_KEY" \
-H "Content-Type: application/json" \
-d '{"n":12}'const res = await fetch("https://api.kit.forhosting.com/numth/totatives-list", {
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.KIT_KEY}`,
"Content-Type": "application/json"
},
body: JSON.stringify({
"n": 12
})
});
const { task_id } = await res.json();import os, requests
res = requests.post(
"https://api.kit.forhosting.com/numth/totatives-list",
headers={"Authorization": f"Bearer {os.environ['KIT_KEY']}"},
json={
"n": 12
},
)
task_id = res.json()["task_id"]<?php
$res = file_get_contents("https://api.kit.forhosting.com/numth/totatives-list", false, stream_context_create([
"http" => [
"method" => "POST",
"header" => "Authorization: Bearer " . getenv("KIT_KEY") . "\r\nContent-Type: application/json",
"content" => '{"n":12}',
],
]));
$task = json_decode($res, true);body := bytes.NewBufferString(`{"n":12}`)
req, _ := http.NewRequest("POST", "https://api.kit.forhosting.com/numth/totatives-list", body)
req.Header.Set("Authorization", "Bearer "+os.Getenv("KIT_KEY"))
req.Header.Set("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)Example request
{
"n": 12
}Example response
{
"task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
"type": "numth.totatives_list",
"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.
Pricing
Published price — no tokens, no invented credits. A failed task is never charged.
Limits
max_n | 100000 |
Errors
| HTTP | Code | Meaning |
|---|---|---|
401 | unauthorized | Missing or invalid API key. |
402 | insufficient_balance | Your balance doesn't cover the task price. |
404 | unknown_type | That task type doesn't exist. |
429 | rate_limited | Too many requests. Use the webhook instead of polling. |