Skip to content

Instantly share code, notes, and snippets.

@Hafthor
Last active November 19, 2022 19:45
Show Gist options
  • Save Hafthor/457ec56c95b187e73956f6f558701077 to your computer and use it in GitHub Desktop.
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)
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