Why math.gcd compute faster than %?

Formatted, please. Otherwise it’s still not usable, has for example “e1e2” (not showing the * between) and invalid quotes. Also, it uses a2 which doesn’t exist.

And I’m quite certain that Tim’s answer doesn’t explain your times, because your times probably aren’t even true. Your whole code should only take a split second. And when I tried modulo and gcd with similar numbers, modulo was about five times faster. About 8 microseconds vs 40 microseconds.

1 Like