Number Theory Operation
number_theory_operationPerform primality testing, integer factorization, next prime, gcd, and lcm calculations with SageMath's reliable number theory engine.
Instructions
Number theory: primality testing, integer factorisation, the next prime above n, gcd and lcm. Prefer this over evaluate_sage for any of these.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"operation": "<operation>",
"a": "<a>"
},
"name": "number_theory_operation"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| a | Yes | Primary integer. Pass values above 2^53 as a decimal STRING: JSON numbers are IEEE doubles in JavaScript-based clients, so 10^30 arrives as 1000000000000000019884624838656 and the answer is silently wrong. | |
| b | No | Second integer, required for gcd and lcm. Same string rule. | |
| session | No | Workspace to use, as a name or a portable handle. Workspaces have independent variables. A name is scoped to this MCP session; a handle returned by start_sage_session (workspace_token) reaches the same workspace across reconnects and is a bearer credential -- keep it secret. Omit for 'default'. | default |
| operation | Yes | Operation: 'is_prime', 'factor_integer', 'next_prime', 'gcd', 'lcm' |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||