Raising a number to a huge power and reducing it modulo another number is the single most common operation in public-key cryptography. Done naively it is impossible — 6517 already has 31 digits, and real exponents have hundreds. Done by square and multiply, it takes a few dozen steps.
Arbitrary size — the arithmetic uses BigInt, so 600-digit inputs are fine. Everything runs in your browser.
Why square and multiply works
Instead of multiplying a by itself b times, you repeatedly square the base and multiply the running result only where the exponent has a 1 bit. An exponent with 2048 bits needs about 2048 squarings rather than 22048 multiplications.
Reducing modulo n at every step keeps every intermediate number below n², so nothing ever grows out of control. That is why your phone can do RSA with 600-digit numbers in milliseconds.
17 in binary = 10001
→ square five times, multiply at bits 0 and 4
→ 2790
This is the operation underneath RSA encryption and Diffie–Hellman key exchange. Reversing it — recovering the exponent — is the discrete logarithm problem, and nobody knows how to do that efficiently.