Ответ:
#include <iostream>
using namespace std;
int gcd(int a, int b) {
while (b != 0) {
int r = a % b;
a = b;
b = r;
}
return a;
int main() {
int a, b, c;
cin >> a >> b >> c;
int gcd_ab = gcd(a, b);
int gcd_abc = gcd(gcd_ab, c);
cout << "НОД(" << a << ", " << b << ", " << c << ") = НОД(НОД(" << a << ", " << b << "), " << c << ") = " << gcd_abc << endl;
return 0;
Copyright © 2024 SCHOLAR.TIPS - All rights reserved.
Answers & Comments
Ответ:
#include <iostream>
using namespace std;
int gcd(int a, int b) {
while (b != 0) {
int r = a % b;
a = b;
b = r;
}
return a;
}
int main() {
int a, b, c;
cin >> a >> b >> c;
int gcd_ab = gcd(a, b);
int gcd_abc = gcd(gcd_ab, c);
cout << "НОД(" << a << ", " << b << ", " << c << ") = НОД(НОД(" << a << ", " << b << "), " << c << ") = " << gcd_abc << endl;
return 0;
}