Skip to content

Instantly share code, notes, and snippets.

@u7karshs
Last active June 20, 2020 10:54
Show Gist options
  • Save u7karshs/79a0dca9446d68f9da142ea0b8b7972a to your computer and use it in GitHub Desktop.
Save u7karshs/79a0dca9446d68f9da142ea0b8b7972a to your computer and use it in GitHub Desktop.
Fast GCD using property (c++)
#include <iostream>
int64_t gcd(int64_t a, int64_t b) {
if(b==0)
return a;
a=a%b;
return gcd(b,a);
}
int main() {
int64_t a, b;
std::cin >> a >> b;
std::cout << gcd(a, b) << std::endl;
return 0;}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment