NT_PHI Function (Gnumeric)
Calculate Euler’s totient with Gnumeric NT_PHI, including coprime counts, prime-power formulas, multiplicative checks and native input rules.
Verification status: 18 reference, boundary and advanced-check formulas were recalculated with Gnumeric 1.12.57 ssconvert. Retained native records and independent integer calculations were checked. Version 1.12.62 was source-checked only. How formula examples are checked
Quick answer: =NT_PHI(1) gives 1 in the tested Gnumeric 1.12.57 build.
Availability and version history
- Introduced: First release not established; present in the retained 1.12.57 source.
- Supported in: Gnumeric 1.12.62; no retirement is established.
- Scope: Desktop Gnumeric with its Number Theory plugin. English comma-separated formulas are shown.
- Checked: October 14, 2026. Tables and the named advanced check were recalculated with 1.12.57 ssconvert. Current 1.12.62 source was inspected; the later release was not executed.
What NT_PHI returns
NT_PHI returns Euler’s totient: the number of integers from 1 through n that are coprime to n. For 9, the qualifying integers are 1, 2, 4, 5, 7 and 8, giving 6. The conventional value at 1 is 1. Versioned function help.
Syntax and arguments
=NT_PHI(n)
n is one required numeric argument. The wrapper floors it and then requires a positive integer within the version-specific bound. For example, 9.9 is treated as 9. This acceptance does not make fractional values part of the mathematical totient domain; it is a conversion rule.
Reproducible examples
These eight native integer results were independently checked by binary arithmetic or elementary number theory.
| Formula | Gnumeric 1.12.57 result |
|---|---|
=NT_PHI(1) |
1 |
=NT_PHI(2) |
1 |
=NT_PHI(9) |
6 |
=NT_PHI(10) |
4 |
=NT_PHI(12) |
4 |
=NT_PHI(36) |
12 |
=NT_PHI(60) |
16 |
=NT_PHI(97) |
96 |
Practical worksheet
If A2 holds a small positive integer, =NT_PHI(A2) returns the number of coprime residues in its complete residue system. For 12, only 1, 5, 7 and 11 qualify, so the result is 4. A worksheet can place n, its prime factorization and the totient in adjacent columns to check the relationship.
For a prime p, every integer from 1 through p−1 is coprime to p, so phi(p)=p−1. The reference row for 97 therefore returns 96. This identity explains the result without interpreting it as a probability.
Advanced interpretation and checks
If n has distinct prime factors p, then phi(n)=n times the product of (1−1/p). For 60=2²×3×5, the result is 60×1/2×2/3×4/5=16. A prime power obeys phi(p^a)=p^(a−1)(p−1).
The function is multiplicative for coprime factors, not for every pair. Since 9 and 10 are coprime, =NT_PHI(9*10)-NT_PHI(9)*NT_PHI(10) returned 0. In contrast, phi(4)=2 whereas phi(2)phi(2)=1, so dropping the coprimality condition would be wrong.
Version-specific source differences
For the standard binary64 build, the older shared input bound is 2^52 = 4503599627370496. The pinned 1.12.62 expression raises it to 2^53 = 9007199254740992. This change is established by comparing the older bound with the current bound; it is not a native test of 1.12.62. Input acceptance and exact representability of every resulting integer are separate questions.
Boundaries and troubleshooting
Zero, negative values and fractions below 1 become invalid inputs. An empty cell also becomes zero in the tested call. The wrapper returns #NUM! for its numeric-range guard and may return #LIMIT! when factorization cannot proceed. Small ordinary cases do not establish performance or exactness for every representable integer.
F5 is an actually empty cell. Listed errors are native error results, not mathematical zeroes.
| Formula | Gnumeric 1.12.57 result |
|---|---|
=NT_PHI(0) |
#NUM! |
=NT_PHI(-1) |
#NUM! |
=NT_PHI(0.9) |
#NUM! |
=NT_PHI(9.9) |
6 |
=NT_PHI("abc") |
#VALUE! |
=NT_PHI(F5) |
#NUM! |
=NT_PHI(TRUE()) |
1 |
=NT_PHI() |
#N/A |
=NT_PHI(9007199254740994) |
#NUM! |
Official evidence and checking scope
- Current worksheet implementation
- Tested-version worksheet implementation
- Current calculation helper
- Tested-version calculation helper
The retained workbook contained a deliberately stale SUM cache and an uncached SUM formula, both recalculated correctly. Native evidence covers the listed 1.12.57 cases. Other worksheet layouts and mathematical interpretations are separately explained checks. GUI entry, other locales and later-release output were not tested.