analyze-prime-numbers
Analyze prime numbers using primality tests, factorization algorithms, prime distribution analysis, and sieve methods.
Skill by Philipp Thoss
Install
Works with Claude Code, Claude apps, Codex, Cursor, Gemini CLI, GitHub Copilot, VS Code, OpenCode, Goose, Windsurf. Read the repository before you give any tool access to your data.
npx agentmarket install skill/pjt222-analyze-prime-numbers
Asks which of your tools to add it to (Claude Code, Codex, Cursor, VS Code, Windsurf, Gemini CLI, Claude Desktop) and shows the change first. See https://agentmart.dev/cli.
Get the weekly diff
The weekly diff: one email a week with new agent tools, notable updates and grade changes, plus security alerts for tools you follow. Double opt-in, one-click unsubscribe.
About
Reviews
Write a reviewNo reviews yet. Installed it? Reviews come from verified installers only. How reviews work
Permissions
What this skill can do and what it asks for, from its SKILL.md. Checked Oct 25, 2026.
- Tools
- No tools found
- Secrets
- None asked for
- Install scripts
- None found
Network hosts it talks to 1
codeload.github.com· found in install command
Files it touches
~/.claude/skills/analyze-prime-numbers
Tools it pre-approves 2
From allowed-tools in SKILL.md: the agent may use these without asking you each time.
ReadBash
What's inside
- Skill name
analyze-prime-numbers- Description
- Analyze prime numbers using primality tests, factorization algorithms, prime distribution analysis, and sieve methods. Covers trial division, Miller-Rabin, Sieve of Eratosthenes, and the Prime Number Theorem. Use when determining whether an integer is prime or composite, finding prime factorizations, counting or listing primes up to a bound, or investigating prime properties within a number-theoretic proof or computation.
- License
- MIT
- Allowed tools
- Read, Bash
- Metadata
- tags: number-theory, primes, primality, factorization, sieve · author: Philipp Thoss · domain: number-theory · version: 1.0 · language: multi · complexity: intermediate
- Instructions
- 215 lines in SKILL.md · view on GitHub
Before installing
- Pre-approves any shell command
Files (1)
- SKILL.md
SKILL.md (first lines)
# Analyze Prime Numbers
Analyze prime numbers by selecting and applying the appropriate algorithm for the task at hand: primality testing, integer factorization, or prime distribution analysis. Verify results computationally and relate findings to the Prime Number Theorem.
## When to Use
- Determining whether a given integer is prime or composite
- Finding the complete prime factorization of an integer
- Counting or listing primes up to a given bound
- Verifying the Prime Number Theorem approximation for a specific range
- Investigating properties of primes in a number-theoretic proof or computation
## Inputs
- **Required**: The integer(s) to analyze, or a bound for distribution analysis
- **Required**: Task type -- one of: primality test, factorization, or distribution analysis
- **Optional**: Preferred algorithm (trial division, Miller-Rabin, Sieve of Eratosthenes, Pollard's rho)
- **Optional**: Whether to produce a formal proof of primality or a computational verdict
- **Optional**: Output format (factor tree, prime list, count, table)
## Procedure
### Step 1: Determine the Task Type
Classify the request into one of three categories and select the appropriate algorithmic path.
1. **Primality test**: Given a single integer n, determine whether n is prime.
2. **Factorization**: Given a composite integer n, find its complete prime factorization.
3. **Distribution analysis**: Given a bound N, analyze the primes up to N (count, list, gaps, density).
Record the task type and the input value(s).
**Got:** A clear classification with the input values recorded.
**If fail:** If the input is ambiguous (e.g., "analyze 60"), ask the user to clarify whether they want a primality test, factorization, or distribution analysis. Default to factorization for composite numbers and primality confirmation for suspected primes.
### Step 2: Apply Primality Testing (if task = primality)
Test whether n is prime using an algorithm matched to the size of n.
1. **Handle trivial cases**: n < 2 is not prime. n = 2 or n = 3 is prime. If n is even and n > 2, it is composite.
2. **Small n (n < 10^6)**: Use trial division.
- Test divisibility by all primes p up to floor(sqrt(n)).
- Optimization: test 2, then odd numbers 3, 5, 7, ... or use a 6k +/- 1 wheel.
- If no divisor found, n is prime.
3. **Large n (n >= 10^6)**: Use Miller-Rabin probabilistic test.
- Write n - 1 = 2^s * d where d is odd.
- For each witness a in {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37}:
- Compute x = a^d mod n.
- If x = 1 or x = n - 1, this witness passes.
- Otherwise, square x up to s - 1 times. If x ever equals n - 1, pass.
- If no pass, n is composite (a is a witness).
- For n < 3.317 * 10^24, the witnesses {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37} give a deterministic result.
4. **Record the verdict**: prime or composite, with the witness or certificate.
**Small primes reference (first 25):**
| Index | Prime | Index | Prime | Index | Prime |
|---|---|---|---|---|---|
| 1 | 2 | 10 | 29 | 19 | 67 |
| 2 | 3 | 11 | 31 | 20 | 71 |
| 3 | 5 | 12 | 37 | 21 | 73 |
| 4 | 7 | 13 | 41 | 22 | 79 |
| 5 | 11 | 14 | 43 | 23 | 83 |
| 6 | 13 | 15 | 47 | 24 | 89 |
| 7 | 17 | 16 | 53 | 25 | 97 |
| 8 | 19 | 17 | 59 | | |
| 9 | 23 | 18 | 61 | | |
**Got:** A definitive answer (prime or composite) with the algorithm used and any witnesses or divisors found.
**If fail:** If Miller-Rabin reports "probably prime" but certainty is required, escalate to a deterministic test (e.g., AKS or ECPP). For trial division, if computation is too slow, switch to Miller-Rabin.
### Step 3: Apply Factorization (if task = factorization)
Factor n completely into its prime power decomposition.
1. **Extract small factors by trial division**:
- Divide out 2 as many times as possible, recording the exponent.
- Divide out odd primes 3, 5, 7, 11, ... up to a cutoff (e.g., 10^4 or sqrt(n) if n is small).
- After each division, update n to the remaining cofactor.
2. **If cofactor > 1 and cofactor < 10^12**: Continue trial division up to sqrt(cofactor).
3. **If cofactor > 1 and cofactor >= 10^12**: Apply Pollard's rho algorithm.
- Choose f(x) = x^2 + c (mod n) with random c.
- Use Floyd's cycle detection: x = f(x), y = f(f(y)).
- Compute d = gcd(|x - y|, n) at each step.
- If 1 < d < n, d is a non-trivial factor. Recurse on d and n/d.
- If d = n, retry with a different c.
4. **Verify**: Multiply all found prime factors (with exponents) and confirm the product equals the original n. Test each factor for primality.
5. **Present the result** in standard form: n = p1^a1 * p2^a2 * ... * pk^ak with p1 < p2 < ... < pk.
**Algorithm complexity notes:**
| Algorithm | Complexity | Best for |
|---|---|---|
| Trial division | O(sqrt(n)) | n < 10^12 |
| Pollard's rho | O(n^{1/4}) expected | n up to ~10^18 |
| Quadratic sieve | L(n)^{1+o(1)} | n up to ~10^50 |
| GNFS | L(n)^{(64/9)^{1/3}+o(1)} | n > 10^50 |
**Got:** A complete prime factorization in canonical form, verified by multiplication.
**If fail:** If Pollard's rho fails to find a factor after many iterations (cycle detected without a non-trivial gcd), try different values of c (at least 5 attempts). If all fail, the cofactor may be prime -- confirm with a primality test.
### Step 4: Apply Distribution Analysis (if task = distribution)
Analyze the distribution of primes up to a given bound N.
1. **Generate primes using the Sieve of Eratosthenes**:
- Create a boolean array of size N + 1, initialized to true.
- Set indices 0 and 1 to false (not prime).
- For each p from 2 to floor(sqrt(N)):From pjt222/agent-almanac, MIT.
More from pjt222/agent-almanac
- 0.616score
adaptic
Philipp Thoss
Master skill composing the 5-step synoptic cycle for panoramic synthesis across multiple domains.
SkillBFreshness: B★ 42Claude Code +9 - 0.616score
add-puzzle-type
Philipp Thoss
Scaffold a new puzzle type across all 10+ pipeline integration points in jigsawR.
SkillBFreshness: B★ 42Claude Code +9 - 0.616score
add-rcpp-integration
Philipp Thoss
Add Rcpp or RcppArmadillo integration to an R package for high-performance C++ code.
SkillBFreshness: B★ 42Claude Code +9 - 0.616score
aikido
Philipp Thoss
Practice aikido as a defensive martial art emphasizing harmony, redirection, and controlled resolution.
SkillBFreshness: B★ 42Claude Code +9 - 0.616score
analyze-codebase-for-mcp
Philipp Thoss
Analyze an arbitrary codebase to identify functions, APIs, and data sources suitable for exposure as MCP tools, producing a tool specification document.
SkillBFreshness: B★ 42Claude Code +9 - 0.616score
analyze-codebase-workflow
Philipp Thoss
Analyze an arbitrary codebase to auto-detect workflows, data pipelines, and file dependencies using putior's put_auto() engine.
SkillBFreshness: B★ 42Claude Code +9 - 0.616score
analyze-diffusion-dynamics
Philipp Thoss
Analyze the dynamics of diffusion processes using stochastic differential equations, Fokker-Planck equations, first-passage time distributions, and parameter…
SkillBFreshness: B★ 42Claude Code +9 - 0.616score
analyze-generative-diffusion-model
Philipp Thoss
Analyze pre-trained generative diffusion models (Stable Diffusion, DALL-E, Flux) by computing quality metrics (FID, IS, CLIP score, precision/recall)…
SkillBFreshness: B★ 42Claude Code +9 - 0.616score
analyze-kernel-bottleneck
Philipp Thoss
Systematically identify whether a GPU kernel is compute-bound, memory-bound, or latency-bound using roofline analysis, occupancy calculations, compute/load…
SkillBFreshness: B★ 42Claude Code +9 - 0.616score
analyze-magnetic-field
Philipp Thoss
Calculate and visualize magnetic fields produced by current distributions using the Biot-Savart law, Ampere's law, and magnetic dipole approximations.
SkillBFreshness: B★ 42Claude Code - 0.616score
analyze-magnetic-levitation
Philipp Thoss
Analyze magnetic levitation systems by applying Earnshaw's theorem to determine whether passive static levitation is possible, then identifying the…
SkillBFreshness: B★ 42Claude Code - 0.616score
adapt-architecture
Philipp Thoss
Execute structural metamorphosis using strangler fig migration, chrysalis phases, and interface preservation.
SkillBFreshness: B★ 42Claude Code +9
Signals
- Stars
- 42
- Forks
- 5
- Open issues
- 182
- Last commit (this folder)
- Aug 17, 2026 (2 months ago)
- Last release
- Aug 26, 2026 (2 months ago)
From GitHub (fetched Oct 24, 2026).
Details
- Version
- 1.0
- License
- MIT
- Repository
- github.com/pjt222/agent-almanac
- First seen
- Oct 24, 2026
- Last checked
- Oct 24, 2026
- Source
- GitHubgithub-graphql
More from Philipp Thoss
- 0.616score
adaptic
Philipp Thoss
Master skill composing the 5-step synoptic cycle for panoramic synthesis across multiple domains.
SkillBFreshness: B★ 42Claude Code +9 - 0.616score
add-puzzle-type
Philipp Thoss
Scaffold a new puzzle type across all 10+ pipeline integration points in jigsawR.
SkillBFreshness: B★ 42Claude Code +9 - 0.616score
add-rcpp-integration
Philipp Thoss
Add Rcpp or RcppArmadillo integration to an R package for high-performance C++ code.
SkillBFreshness: B★ 42Claude Code +9 - 0.616score
aikido
Philipp Thoss
Practice aikido as a defensive martial art emphasizing harmony, redirection, and controlled resolution.
SkillBFreshness: B★ 42Claude Code +9 - 0.616score
analyze-codebase-for-mcp
Philipp Thoss
Analyze an arbitrary codebase to identify functions, APIs, and data sources suitable for exposure as MCP tools, producing a tool specification document.
SkillBFreshness: B★ 42Claude Code +9 - 0.616score
adapt-architecture
Philipp Thoss
Execute structural metamorphosis using strangler fig migration, chrysalis phases, and interface preservation.
SkillBFreshness: B★ 42Claude Code +9
Cite this page
analyze-prime-numbers skill. Agent Mart. https://agentmart.dev/skills/pjt222-analyze-prime-numbers (last updated 2026-10-24)