Skip to content

Instantly share code, notes, and snippets.

@dionyziz
Last active December 26, 2015 14:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dionyziz/7165576 to your computer and use it in GitHub Desktop.
Save dionyziz/7165576 to your computer and use it in GitHub Desktop.
#include <cassert>
int gcd(int a, int b) {
assert(b < a);
assert(b >= 0);
assert(a >= 0);
if (b == 0) {
assert(a > 0);
return a;
}
int result = gcd(b, a % b);
assert(result > 0);
return result;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment