Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int suma(int a, int b) {
- int sum = 0;
- for (int d = 1; d <= a && d <= b; d++) {
- if (a % d == 0 && b % d == 0) {
- sum += d;
- }
- }
- return sum;
- }
- int main() {
- cout << suma(20, 12) << endl;//7
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement