Advertisement
Spocoman

06. Greatest Common Divisor

Oct 26th, 2023 (edited)
655
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.30 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main() {
  6.     int firstNumber, secondNumber;
  7.     cin >> firstNumber >> secondNumber;
  8.  
  9.     for (int i = 10; i > 0; i--) {
  10.         if (firstNumber % i == 0 && secondNumber % i == 0) {
  11.             cout << i << endl;
  12.             return 0;
  13.         }
  14.     }
  15. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement