SHARE
TWEET

Untitled

a guest Oct 23rd, 2019 49 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int nok(int a, int b) {
  5.     int max = b;
  6.     for (int i = max; i > 0; i++) {
  7.         if ((i % a == 0) && (i % b == 0)) {
  8.             return i;
  9.         }
  10.     }
  11. }
  12.  
  13. int main() {
  14.     int a, b, ans = 1;
  15.     cin >> a >> b;
  16.     while (!((ans - 1) % a == 0 && (ans + 1) % b == 0)) {
  17.         ans++;
  18.     }
  19.     cout << ans << endl;
  20.     return 0;
  21. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top