Last active
November 19, 2022 19:45
-
-
Save Hafthor/457ec56c95b187e73956f6f558701077 to your computer and use it in GitHub Desktop.
Greatest Common Factor using Euclid's algorithm and, gasp, gotos to be fast (about 50% faster)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static long gcf(long m, long n) | |
{ | |
if (m < n) goto l2; | |
l1: if ((m %= n) == 0) return n; | |
l2: if ((n %= m) == 0) return m; | |
goto l1; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment