Integer totient
integer-totient · version 1.0.0 · Numbers & math · free, no key needed
Compute Euler's totient function: the count of integers in [1, value] coprime to value.
Use when you need to: integer totient · euler's totient function · euler phi function.
Supported
- integer totient
- euler's totient function
- euler phi function
- count coprime integers
Not supported
- totient of 0 or negative integers
- carmichael function
- totient summatory function
Behavior
- value is a canonical positive integer string from 1 to 1000000000000 (10^12) inclusive.
- 0 and negative values are rejected: the totient is only defined here for positive integers.
- value 1 returns 1 by convention (the empty product / one coprime residue).
- Computed exactly from the prime factorization as value * product over distinct primes p dividing value of (1 - 1/p), using integer arithmetic only (no floating point).
- Derivation uses exact trial division up to sqrt(value), bounded by the 10^12 input cap for predictable running time.
Input
value(string, required): max length 13; pattern^[1-9][0-9]*$
Output
value(string, required)
Limits
- max value: 1000000000000
- max digits: 13
Example
Request input:
{
"value": "36"
}
Response:
{
"result": {
"value": "12"
}
}
How to call it
MCP
Connect https://computefirst.net/mcp (setup), then call execute with:
{
"id": "integer-totient",
"version": "1.0.0",
"input": {
"value": "36"
}
}
HTTP (no key)
curl -X POST https://computefirst.net/v1/tools/integer-totient/versions/1.0.0/execute \
-H "Content-Type: application/json" \
-d '{"value":"36"}'
The machine-readable contract is at /v1/tools/integer-totient/versions/1.0.0.
CLI
node cli.mjs run integer-totient 1.0.0 --input input.json --base-url https://computefirst.net
Get the client at /clients/cli/.
Related tools
- Array integer GCD: Compute the non-negative greatest common divisor of an array of canonical integer strings.
- Array integer LCM: Compute the non-negative least common multiple of an array of canonical integer strings.
- Array integer min max: Return the numeric minimum and maximum of canonical integer strings.
- Array integer mode: Return the most frequent canonical integers, listing every mode in first-seen order.
- Array integer ranks: Assign competition (1224) ranks to canonical integers; ties share the minimum rank.
- Integer add: Add two canonical signed integer strings and return their canonical sum.