{"uid":"cap_ooM9NxGpu5hk3Lzm9xAt2","slug":"agent402-tools-modular-arithmetic-bf12def3","name":"agent402.tools Modular Arithmetic","description":"Modular arithmetic operations: mod (a mod m), modpow (a^b mod m via fast exponentiation), and modinverse (a^-1 mod m via extended Euclidean algorithm). Uses BigInt for arbitrary precision. Useful for cryptography and number theory.","url":"https://agent402.tools/api/mod-arithmetic","method":"POST","headers":{},"bodySchema":{"type":"object","properties":{"a":{"type":"integer","description":"base value"},"b":{"type":"integer","description":"exponent (required for modpow)"},"m":{"type":"integer","description":"modulus (must be > 0)"},"op":{"type":"string","description":"\"mod\", \"modpow\", or \"modinverse\""}}},"responseSchema":{"type":"json","example":{"a":"7","b":"256","m":"13","op":"modpow","result":"9"}},"example":null,"exampleRequest":null,"tags":["x402"],"displayCostAmount":"0.001","displayCostAsset":"USDC","priceDynamic":false,"priceHint":null,"priceStatus":"priced","priceSource":"probe","requiresHandshake":false,"reviewCount":0,"rating":{"score":"0.00","successRate":"0.00","reviews":0,"stars":null,"state":"unrated"},"availabilityStatus":"unknown","priceObserved":null,"sessionDeposit":null,"pricing":{"kind":"static","summary":"$0.001/call","primary":{"kind":"static","protocol":"x402","network":"base","amountUsd":"0.001","per":"call","confidence":"exact"},"accepted":[{"kind":"static","protocol":"x402","network":"base","amountUsd":"0.001","per":"call","confidence":"exact"}]},"paymentMethods":[{"uid":"pm_uaHhA1Atk8U7jpB7BuDKy","protocol":"x402","methodType":"crypto","chain":"base","mode":"charge","costAmount":"0.001","costPer":"request","priority":0,"asset":"0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913","unit":"request","depositMicros":null,"planRef":null}],"brandName":null,"brandSlug":null,"brandBaseUrl":null,"brandDocsUrl":null,"whatItDoes":"Performs modular arithmetic operations (mod, modpow, modinverse) using arbitrary-precision BigInt arithmetic for cryptography and number theory applications.","exampleAgentPrompt":"Can you compute 2 to the power of 100 mod 1000000007 using fast modular exponentiation (modpow), with a=2, b=100, and m=1000000007?","exampleUseCases":null,"resultDescription":"A numeric result corresponding to the requested modular arithmetic operation: a mod m for 'mod', a^b mod m for 'modpow', or the modular inverse a^-1 mod m for 'modinverse', all computed using arbitrary-precision BigInt arithmetic.","failureModes":["Modulus m <= 0 results in an error (modulus must be positive)","modinverse fails if no modular inverse exists (when gcd(a, m) != 1)","Missing required parameter 'b' for modpow operation","Invalid 'op' string (must be 'mod', 'modpow', or 'modinverse')","Non-integer inputs cause validation failure"],"whenToPreferThis":"Use this endpoint when you need arbitrary-precision modular arithmetic, especially for cryptographic protocols (RSA, Diffie-Hellman), primality testing, or number theory calculations where standard integer overflow would be a problem. Prefer over general-purpose math libraries when you need a hosted, pay-per-call API with BigInt support.","instructions":null,"reviewSummary":null,"reviewSummaryHighlights":null,"reviewSummaryConcerns":null,"reviewSummaryGeneratedAt":null,"activationCount":0,"lastUsedAt":null,"lastSuccessfullyRanAt":null,"lastHealthCheckAt":"2026-09-14T19:14:03.630Z","isFirstParty":false}