Use this skill when working on modular-arithmetic problems in graph number theory.
Decision Tree
Extended Euclidean Algorithm
Find gcd(a,b) and x,y with ax + by = gcd(a,b)
Modular inverse: a^{-1} mod n when gcd(a,n) = 1
sympy_compute.py solve "a*x == 1 mod n"
Chinese Remainder Theorem
System x = a_i (mod m_i) with coprime m_i
Unique solution mod prod(m_i)
z3_solve.py prove "crt_solution_exists"
Euler's Theorem
a^{phi(n)} = 1 (mod n) when gcd(a,n) = 1
phi(p^k) = p^{k-1}(p-1)
sympy_compute.py simplify "euler_phi"
Quadratic Residues
Legendre symbol: (a/p) = a^{(p-1)/2} mod p
Quadratic reciprocity: (p/q)(q/p) = (-1)^{...}
Tonelli-Shanks for square roots
Order and Primitive Roots
ord_n(a) = smallest k with a^k = 1 (mod n)
Primitive root: ord_n(a) = phi(n)
Tool Commands
Sympy_Mod_Inverse
uv run python -m runtime.harness scripts/sympy_compute.py solve "a*x == 1 mod n" --var x
Z3_Crt
uv run python -m runtime.harness scripts/z3_solve.py prove "solution_exists_iff_pairwise_coprime"
Sympy_Euler_Phi
uv run python -m runtime.harness scripts/sympy_compute.py simplify "phi(p**k) == p**(k-1)*(p-1)"
Z3_Quadratic_Residue
uv run python -m runtime.harness scripts/z3_solve.py prove "legendre_symbol_multiplicative"
Key Techniques
From indexed textbooks:
[Graph Theory (Graduate Texts in Mathematics (173))] By N we denote the set of natural numbers, including zero. The set Z/nZ of integers modulo n is denoted by Zn; its elements are written as i := i + nZ. When we regard Z2 = {0, 1} as a eld, we also denote it as F2 = {0, 1}.
Cognitive Tools Reference
See .claude/skills/math-mode/SKILL.md for full tool documentation.
1---2name: modular-arithmetic3description: Modular Arithmetic4---56# Modular Arithmetic78## When to Use910Use this skill when working on modular-arithmetic problems in graph number theory.1112## Decision Tree1314151. **Extended Euclidean Algorithm**16 - Find gcd(a,b) and x,y with ax + by = gcd(a,b)17 - Modular inverse: a^{-1} mod n when gcd(a,n) = 118 - `sympy_compute.py solve "a*x == 1 mod n"`19202. **Chinese Remainder Theorem**21 - System x = a_i (mod m_i) with coprime m_i22 - Unique solution mod prod(m_i)23 - `z3_solve.py prove "crt_solution_exists"`24253. **Euler's Theorem**26 - a^{phi(n)} = 1 (mod n) when gcd(a,n) = 127 - phi(p^k) = p^{k-1}(p-1)28 - `sympy_compute.py simplify "euler_phi"`29304. **Quadratic Residues**31 - Legendre symbol: (a/p) = a^{(p-1)/2} mod p32 - Quadratic reciprocity: (p/q)(q/p) = (-1)^{...}33 - Tonelli-Shanks for square roots34355. **Order and Primitive Roots**36 - ord_n(a) = smallest k with a^k = 1 (mod n)37 - Primitive root: ord_n(a) = phi(n)383940## Tool Commands4142### Sympy_Mod_Inverse43```bash44uv run python -m runtime.harness scripts/sympy_compute.py solve "a*x == 1 mod n" --var x45```4647### Z3_Crt48```bash49uv run python -m runtime.harness scripts/z3_solve.py prove "solution_exists_iff_pairwise_coprime"50```5152### Sympy_Euler_Phi53```bash54uv run python -m runtime.harness scripts/sympy_compute.py simplify "phi(p**k) == p**(k-1)*(p-1)"55```5657### Z3_Quadratic_Residue58```bash59uv run python -m runtime.harness scripts/z3_solve.py prove "legendre_symbol_multiplicative"60```6162## Key Techniques6364*From indexed textbooks:*6566- [Graph Theory (Graduate Texts in Mathematics (173))] By N we denote the set of natural numbers, including zero. The set Z/nZ of integers modulo n is denoted by Zn; its elements are written as i := i + nZ. When we regard Z2 = {0, 1} as a eld, we also denote it as F2 = {0, 1}.6768## Cognitive Tools Reference6970See `.claude/skills/math-mode/SKILL.md` for full tool documentation.
Run npx skillmds@latest add dojogenesis/modular-arithmetic in your terminal (requires Node.js), paste this page's agent-chat prompt into Claude, Cursor, or any MCP-connected agent, or download the SKILL.md file and copy it into your agent's skills directory.
Modular Arithmetic It is listed under Coding & Dev Tools on SkillMD.
This skill has not completed SkillMD's automated safety review yet. SkillMD never runs a skill's scripts for you; review the SKILL.md before installing.
This skill is tagged as working with Claude Code, Claude.ai, OpenAI Codex. SKILL.md is an open format, so most agents that read a skills directory can load it too.
Yes. Installing skills from SkillMD is free, and the skill stays under its author's original license.
DojoGenesis (@dojogenesis) published this skill. Their other Agent Skills are listed on their SkillMD profile.