Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- using namespace std;
- int main() {
- int first;
- int second;
- int range;
- cout << "Enter the first number: ";
- cin >> first;
- cout << "Enter the second number: ";
- cin >> second;
- if (abs(first) > abs(second)) {
- range = abs(second);
- }
- else {
- range = abs(first);
- }
- int min = 1;
- for (int i = 2; i <= range; i++) {
- if ((first % i) == 0 && (second % i) == 0) {
- min = i;
- break;
- }
- }
- if (min == 1) {
- cout << "This numbers haven`t general divider!";
- }
- else {
- cout << "The smallest general divider is: " << min;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement