Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Author: Kanan Asgarli
- https://www.e-olymp.com/az/problems/1146
- */
- #include <iostream>
- #include <cmath>
- using namespace std;
- int GCD(int a, int b){
- return b == 0 ? a : GCD(b,a%b);
- }
- int n, G;
- int main()
- {
- while(cin>>n && n != 0){
- for(int i = 1; i < n; i++)
- for(int j = i + 1; j <= n;j++){
- G+=GCD(i,j);
- }
- cout<<G<<endl;
- G = 0;
- }
- return 0;
- }
Add Comment
Please, Sign In to add comment