Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- #include <set>
- #include <cstring>
- #include <queue>
- #include <algorithm>
- using namespace std;
- int gcd(int a, int b) { // bitno e A da e pogolemiot broj, a B da e pomaliot broj
- if(a < b) {
- swap(a, b);
- }
- while(b != 0) {
- int tmp = a;
- a = b;
- b = tmp % b;
- }
- return a;
- }
- int main() {
- cout << gcd(9, 40) << endl;
- cout << gcd(50, 100) << endl;
- return 0;
- }
- /*
- 10 9
- 1 6
- 1 9
- 1 10
- 2 6
- 2 7
- 3 7
- 4 8
- 4 9
- 5 10
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement