prime-numbers
Scannednpx machina-cli add skill parcadei/Continuous-Claude-v3/prime-numbers --openclawPrime Numbers
When to Use
Use this skill when working on prime-numbers problems in graph number theory.
Decision Tree
-
Primality testing hierarchy
- Trial division: O(sqrt(n)), exact
- Miller-Rabin: O(k log^3 n), probabilistic
- AKS: O(log^6 n), deterministic polynomial
-
Factorization
- Trial division for small factors
- Pollard's rho: probabilistic, medium numbers
- Quadratic sieve: large numbers
sympy_compute.py factor "n"
-
Prime distribution
- Prime Number Theorem: pi(x) ~ x/ln(x)
- Prime gaps: p_{n+1} - p_n
sympy_compute.py limit "pi(x) * ln(x) / x"
-
Fermat's Little Theorem
- a^{p-1} = 1 (mod p) for a not divisible by p
- Use for modular exponentiation
z3_solve.py prove "fermat_little"
-
Wilson's Theorem
- (p-1)! = -1 (mod p) iff p is prime
Tool Commands
Sympy_Factor
uv run python -m runtime.harness scripts/sympy_compute.py factor "n"
Z3_Primality
uv run python -m runtime.harness scripts/z3_solve.py prove "no_divisor_between_1_and_sqrt_n"
Sympy_Prime_Count
uv run python -m runtime.harness scripts/sympy_compute.py simplify "pi(x) ~ x/ln(x)"
Z3_Fermat_Little
uv run python -m runtime.harness scripts/z3_solve.py prove "a**(p-1) == 1 mod p"
Key Techniques
From indexed textbooks:
Cognitive Tools Reference
See .claude/skills/math-mode/SKILL.md for full tool documentation.
Source
git clone https://github.com/parcadei/Continuous-Claude-v3/blob/main/.claude/skills/math/graph-number-theory/prime-numbers/SKILL.mdView on GitHub Overview
Learn how primality testing, factorization, and prime-distribution concepts apply to graph-number theory problems. The skill also maps steps to practical tool commands (Sympy, Z3) for computation and verification.
How This Skill Works
Technically, you start with a primality-testing hierarchy: trial division for small n, Miller-Rabin for probabilistic checks, then AKS for deterministic proofs. For factorization, you apply small-factor trial division, Pollard's Rho, and the Quadratic Sieve, often using sympy_compute.py to factor n. For theory and proofs, you use Prime distribution results, Fermat's Little Theorem, and Wilson's Theorem, validated with tool scripts like z3_solve.py and sympy_compute.py.
When to Use It
- When you need to determine primality of numbers that arise in graph-number-theory problems.
- When large composite numbers appear and you require efficient factoring to simplify modular constraints.
- When estimating prime density or gaps in a graph-based numeric setting using pi(x) approximations.
- When proving modular properties for graph-related proofs using Fermat's Little Theorem.
- When validating primality tests or primality-based proofs with Wilson's Theorem.
Quick Start
- Step 1: Identify the numeric parameters at issue and decide primality/testing as needed.
- Step 2: Run a specific computation path, e.g., factor n with SymPy or check primality with Z3: uv run python -m runtime.harness scripts/sympy_compute.py factor n; uv run python -m runtime.harness scripts/z3_solve.py prove no_divisor_between_1_and_sqrt_n
- Step 3: Apply Fermat's Little Theorem or Wilson's Theorem to validate modular results, using tool scripts such as z3_solve.py and sympy_compute.py to verify proofs.
Best Practices
- Start with trial division for small factors (O(sqrt(n))) before heavier methods.
- Use Miller-Rabin with multiple bases for probabilistic certainty, then switch to AKS if a deterministic proof is required.
- Apply factoring methods in order of size: trial division for small factors, Pollard's Rho, then Quadratic Sieve.
- Leverage the provided tool scripts (e.g., sympy_compute.py and z3_solve.py) for real computations.
- Cross-check results with complementary theorems (Fermat's Little Theorem and Wilson's Theorem) when possible.
Example Use Cases
- Identify whether a node-labeling constraint depends on primes and test primality to prune cases.
- Factor a large edge-weight to simplify a congruence condition in a graph modulo problem.
- Estimate pi(x) to study prime distribution within a graph-based number-theory model.
- Use Fermat's Little Theorem to validate modular exponent equations arising from graph constraints.
- Apply Wilson's Theorem to verify primality in a small-prime hard-code check within a proof draft.