3 ms·
Right. This is a consequence of compatibility with exponentiation. https://en.wikipedia.org/wiki/Modular_arithmetic#Properties https://en.wikipedia.org/wiki/Mo
by vitus 6y ago
Right. This is a consequence of compatibility with exponentiation.
https://en.wikipedia.org/wiki/Modular_arithmetic#Properties https://en.wikipedia.org/wiki/Modular_arithmetic#Properties
It should be easy to see that
n ≡ (n % 15) (mod 15)
which, applying compatibility of exp, then gives us
n^4 ≡ (n % 15)^4 (mod 15)
which can be rewritten in Python's notation as
n**4 % 15 == (n % 15) ** 4 % 15