Created
September 12, 2021 16:09
-
-
Save modos/c0787bbe36c521adce0d14aa4c25bf99 to your computer and use it in GitHub Desktop.
دابره عجیب
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/****************************************************************************** | |
Online C++ Compiler. | |
Code, Compile, Run and Debug C++ program online. | |
Write your code in this editor and press "Run" button to compile and execute it. | |
*******************************************************************************/ | |
#include <iostream> | |
using namespace std; | |
int main() | |
{ | |
int n; | |
int k; | |
cin >> n; | |
cin >> k; | |
int sum = 0; | |
int i = 1; | |
if (n == 1 || n == k){ | |
cout << 1; | |
}else { | |
i = i + k; | |
sum = sum + 1; | |
while (i != 1){ | |
i = i + k; | |
if (i == 1){ | |
break; | |
} | |
if ( i > n){ | |
i = i - n; | |
} | |
sum++; | |
} | |
cout << sum; | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment