totient
std.elementwise.totient · Level L4Euler's totient φ(n) for each n ≥ 1: how many k in 1 … n are coprime to n, as n·Π(1 − 1/p) over its prime factors (factor_summary). The reference counts the k directly.
φ(n) = #{1 ≤ k ≤ n : gcd(k, n) = 1} = n·Π(1 − 1/p)
Signature
totient(n: i64[s]) → i64[s]
Structure
The function as NOVA stores it: one box per input, operation and output, and arrows that carry values. A double border marks another library function this one runs — called once, or by Scan once per element; select it to open that function.
- input
- operation
- constant
- call
- output
Verification
- Signature proven by NOVA’s shape solver, for every size.
- Equal to the reference
sum(gcd(k, n) == 1 for k in 1 … n)in exact rational arithmetic, on all 40 test cases. - All 139 int64 results are exact: the error is zero.
- Interpreter and NumPy backend return bit-identical results.
- At float32 too: the 40 test cases rounded to float32, and 40 of them exact, with zero error.
Accuracy in detail
- correctly rounded (the int64 nearest the exact value)
- 100%
- bit-equal to the NumPy formula in int64
- 100%
- largest error, in units in the last place
- 0
Identity
sha256:384ad3a46c2a3ae42f9d3f390a22cd128b35bb0e4dbe091c72731deaa3a211caThe semantic hash of the graph. It changes when the program changes, and never when only its documentation does.
Control handle
- Symbol
- Ω:std.elementwise.totient · Ω:totient
- Pins
sha256:d9d157be79e235ee5e0f3d8f0498cbdcbcd04e1dc2f89e124e28b8fbe77aa888this graph and the 3 it reaches through calls- Evidence
sha256:7bf6782ce564404bce5861e5a4d0ac483e817817f7db12a76036c582418c441fthe hash of its verification record- Needs
- no capability: a pure function
Through NOVA’s control layer, the symbol launches this function only while the program still matches what it pins: a change to this graph, or to any graph it reaches, needs a migration first.