Skip to content

prime(n) is the n-th prime, and valuation(n, p) the p-adic valuation - #1453

Merged
Rafael-SOWNet merged 2 commits into
masterfrom
nth-prime
Sep 21, 2026
Merged

Rafael-SOWNet merged 2 commits into
masterfrom
nth-prime

Conversation

@Rafael-SOWNet

Copy link
Copy Markdown
Member

The two functions #1450's questions come down to, beside the set #1452 added.

prime(n) — the n-th prime, SymPy's spelling: prime(1) is 2, prime(25) is 97, prime(1000) is 7919; NaN off the positive whole numbers; left as written for a symbol or an index past a million, where the table would be built towards it. A function of its own rather than an operation on PP, which carries no order; its codomain is Domain.Prime. The table behind it, Primes.GetPrime, existed already for the continued-fraction code — this exposes it. \operatorname{prime}(n) in LaTeX, sympy.prime(n).

valuation(n, p) — the p-adic valuation, the exponent of the prime p in n: valuation(12, 2) is 2, valuation(12, 5) is 0, valuation(-40, 2) is 3, +oo at n = 0 by the convention every text uses, NaN where p is not prime. Sullivan and Mackey's Ex 5.5.1 writes n = 2^m (2 l + 1) with m the 2-adic valuation, and n = product(p^valuation(n, p), p in PP) is what a factorisation says over the set — the product(f, p in S) binder itself is the multiplicative twin of #1435's union and waits for #1019's indexed-family convention. v_p(n) in LaTeX, sympy.multiplicity(p, n).

Both are nodes through every pipeline (WritingARule.md's buildable count goes 48 → 50), with 22 rows in PrimeSetTest, Syntax.md and BREAKING-CHANGES.md. Full suite 12499 passed; the allocation gate passes on all 19 gated benchmarks — ParseHard +0.7%, which is #1441's ~12 KB per 'name(' token, twice.

Part of #1450.

🤖 Generated with Claude Code

https://claude.ai/code/session_012sonx8iAspMiwRwokT1Ura

Rafael-SOWNet and others added 2 commits September 21, 2026 16:27
A function of its own -- PP carries no order -- with SymPy's spelling: prime(1) is 2, prime(25)
is 97, NaN off the positive whole numbers, and left as written for a symbol or an index past a
million, where the table would be built towards it. Its codomain is Domain.Prime.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012sonx8iAspMiwRwokT1Ura
The exponent of the prime p in n: valuation(12, 2) is 2, valuation(12, 5) is 0, +oo at n = 0 by
the convention, NaN where p is not prime. Sullivan and Mackey's Ex 5.5.1 writes n = 2^m (2 l + 1)
with m the 2-adic valuation, and n = product(p^valuation(n, p), p in PP) is what a factorisation
says over the set of primes. v_p(n) in LaTeX, sympy.multiplicity in SymPy.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012sonx8iAspMiwRwokT1Ura
@Rafael-SOWNet
Rafael-SOWNet merged commit f050d4e into master Sep 21, 2026
32 checks passed
@Rafael-SOWNet
Rafael-SOWNet deleted the nth-prime branch September 21, 2026 16:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant