NT_PI Function (Gnumeric)
Count primes up to a limit with NT_PI in Gnumeric. See inclusive endpoints, interval counts, native examples and the implementation’s resource limits.
Verification status: 18 reference, boundary and advanced-check formulas were recalculated with Gnumeric 1.12.57 ssconvert. Retained identities and results were checked against independent calculations. Gnumeric 1.12.62 was source-checked only. How formula examples are checked
Quick answer: =NT_PI(1) gives 0 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. The tables and named advanced check use 1.12.57 ssconvert. Current 1.12.62 source was inspected; that release was not executed.
What NT_PI returns
NT_PI is the prime-counting function π(n): the number of primes less than or equal to n. It does not return the circle constant π. The endpoint is inclusive, so NT_PI(10)=4 but NT_PI(11)=5 because 11 is prime. Versioned function help.
Syntax and arguments
=NT_PI(n)
n is one numerical cutoff, floored before counting. The source extends the usual nonnegative domain by returning zero for negative cutoffs. Values below two contain no primes.
Reproducible examples
The eight ordinary results below were independently checked using integer arithmetic.
| Formula | Gnumeric 1.12.57 result |
|---|---|
=NT_PI(1) |
0 |
=NT_PI(2) |
1 |
=NT_PI(3) |
2 |
=NT_PI(10) |
4 |
=NT_PI(11) |
5 |
=NT_PI(25) |
9 |
=NT_PI(100) |
25 |
=NT_PI(1000) |
168 |
Practical worksheet
To count primes in an interval (a,b], subtract NT_PI(a) from NT_PI(b). For (10,30], the independent count is 6: 11,13,17,19,23,29. To include both integer endpoints [a,b], use NT_PI(b)-NT_PI(a-1). Keep the endpoints and interval convention visible in the worksheet.
The table’s NT_PI(1000)=168 means 16.8% of integers from 1 through 1000 are prime. That is a count over a fixed interval, not the probability that every later integer is prime.
Advanced interpretation and checks
Prime counting and the nth-prime function are inverse operations on prime endpoints. The native advanced check =NT_PI(ITHPRIME(100)) returns 100; the 100th prime is 541. Between consecutive primes, NT_PI stays constant.
A rough mathematical approximation such as n/log(n) must not replace an exact count in a verification formula. At n=1000 it is about 144.764827301084, whereas the actual count is 168. The approximation has an asymptotic purpose and is visibly inaccurate for this small cutoff.
Version-specific source comparison
In the standard binary64 build, the 1.12.57 shared bound is 2^52 = 4503599627370496. The 1.12.62 source bound is 2^53 = 9007199254740992. The tested large-input rejection is an older-build observation; the newer range was source-checked only. An accepted number is not a guarantee that a resource-intensive prime calculation will complete.
Boundaries and troubleshooting
The function can build a large internal prime table. The shared input bound is not a promise that every cutoff below it is practical or computable. The source’s prime-table helper limits indices to 100000000; a request exceeding supported work can produce #LIMIT!. The table deliberately tests a cutoff beyond the shared numeric bound without attempting a huge near-limit count.
Negative input returning zero is implemented behavior, not evidence that a negative domain contains primes. Missing required arguments still produce #N/A.
F5 is an actually empty cell. Errors below are the tested build’s results, not zero-valued mathematical answers.
| Formula | Gnumeric 1.12.57 result |
|---|---|
=NT_PI(0) |
0 |
=NT_PI(-1) |
0 |
=NT_PI(0.9) |
0 |
=NT_PI(9.9) |
4 |
=NT_PI("abc") |
#VALUE! |
=NT_PI(F5) |
0 |
=NT_PI(TRUE()) |
0 |
=NT_PI() |
#N/A |
=NT_PI(9007199254740994) |
#LIMIT! |
Official evidence and checking scope
- Current worksheet implementation
- Tested-version worksheet implementation
- Current calculation helper
- Prime-table helper and index limit
The retained workbook’s stale SUM cache and uncached SUM both recalculated correctly. Formula identities, typed inputs and native results were inspected. The importer reported unsupported style-extension elements; that warning is retained, and no all-formatting claim is made. GUI entry, other locales and later-release output were not tested.