API & MCP

Everything a person can do on Number-Theory Lab, a program or AI agent can do with the same inputs and get the identical result.

HTTP API

Number-Theory Lab

Big-integer number theory with the working shown: Miller–Rabin primality (deterministic up to 3.3·10^24, otherwise with a stated number of rounds), factorisation by trial division and Pollard rho, gcd/lcm with the extended Euclidean table, modular inverse and exponentiation, the Chinese remainder theorem, Euler φ and divisors, prime counting up to 10 million, Collatz sequences and continued fractions.

Inputs of Number-Theory Lab
FieldTypeDefaultDescription
operationselect (analyze, gcd, modpow, modinv, crt, primecount, collatz, cf)"analyze"Operation
atext"561"n or a. Integer: decimal, 0x hex, 0b binary, or a power such as 2^127-1.
btext—b (second number / exponent / denominator)
mtext—Modulus m
congruencestextarea—Congruences (one per line: remainder modulus). For the CRT: each line "a m" means x ≡ a (mod m). Moduli need not be coprime.
roundsinteger40Miller–Rabin rounds above 3.3·10^24. Error probability at most 4^−rounds for numbers beyond the deterministic range.

Example request

561, the smallest Carmichael number

curl -X POST https://numbertheorylab.usefulweb.site/api/v1/calculate -H 'content-type: application/json' -d '{"operation":"analyze","a":"561"}'

Every result contains

inputs (normalised, defaults applied), summary, result (validated against the published schema), units, assumptions, sources, warnings, computedAt and links.

MCP (Model Context Protocol)

{
  "mcpServers": {
    "number-theory-lab": { "type": "http", "url": "https://numbertheorylab.usefulweb.site/mcp" }
  }
}