thoughtasylumTOOLBOX Preview

Tools › Developer

Calculator

Work out expressions line by line, with exact whole numbers of any size (powers, modular inverse and power, GCD, primes and factors) or ordinary decimals with maths functions.

About this tool What it's for, how to use it and an example

What it's for

Do sums that ordinary calculators can’t: exact arithmetic on whole numbers of any size, with the modular maths, prime tests and factoring that RSA and capture-the-flag puzzles need. Switch to decimals for everyday sums with trigonometry and logarithms.

For example, when a puzzle gives you n, e and a ciphertext, factor n and work out the private key here.

How to use it

Type one expression per line; each line’s result appears beside it as you type. Set variables (p = 61) and use them on later lines; ans is the previous result. The functions are listed under the boxes. Numbers chooses exact whole numbers or decimals, and is remembered. Copy a link to this input keeps the lines.

Example

Choose Try an example, which works through the textbook RSA key with p = 61 and q = 53. The last line encrypts 65 and decrypts it again, and its result is 65.

Good to know

Whole-number division drops the remainder. Factoring gives up after three seconds and shows what’s left unfactored, so numbers with two large prime factors (real RSA keys) won’t factor. Prime tests are certain below about 3 × 10^24 and overwhelmingly likely above. Decimals have about 15 significant digits.

Whole numbers: + − × / (whole division) % ** ! & | ^ (xor) << >>, and gcd, lcm, modinv, modpow, isprime, nextprime, factor, phi, sqrt, bits, digits, min, max, abs. Decimals: ^ is a power, with sin, cos, tan, sqrt, ln, log, exp, pi and more. Set variables with x = 5; ans is the line before; # starts a comment.

Private: this tool runs in your browser. Nothing you type, paste or choose leaves this page.

Saved you a few minutes? Say thanks with a coffee.

Something wrong with this tool, or missing from it? Report a bug or suggest a feature.

↑ ↓ move↵ openesc close