Last active
June 20, 2020 10:54
-
-
Save u7karshs/79a0dca9446d68f9da142ea0b8b7972a to your computer and use it in GitHub Desktop.
Fast GCD using property (c++)
This file contains hidden or 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
| #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