Skip to content

Instantly share code, notes, and snippets.

@carlopi
Created June 26, 2020 11:42
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 carlopi/569bb93fd08cc2f5a792a6d3fdb4e60b to your computer and use it in GitHub Desktop.
Save carlopi/569bb93fd08cc2f5a792a6d3fdb4e60b to your computer and use it in GitHub Desktop.
gcd.cpp
[[cheerp::jsexport]] int gcd(int a, int b)
{
//Euclidean algorithm to compute Greatest Commond Divisor
while (b)
{
int temp = a % b;
a = b;
b = temp;
}
return a;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment