← Back to challenges

Modular Arithmetic (Part #1)

PythonHardmathbugsloops

Instructions

Modify the inefficient code in the Code tab so it can pass the tests.

Examples

mod(base, exp, k) ➞ (base**(2**exp)) % k

mod(10, 1, 99 ) ➞ 1

mod(3, 2, 15 ) ➞ 6

mod(123, 20, 1234 ) ➞ 391

Notes

Try using loops.

python3
Loading editor…
to run
Walks through the solution with reasoning and edge cases.