asgarlikanan

https://www.e-olymp.com/az/problems/1146

Aug 6th, 2016
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
4CS 0.39 KB | None | 0 0
  1. /*
  2.     Author: Kanan Asgarli
  3.     https://www.e-olymp.com/az/problems/1146
  4. */
  5. #include <iostream>
  6. #include <cmath>
  7. using namespace std;
  8. int GCD(int a, int b){
  9.     return b == 0 ? a : GCD(b,a%b);
  10. }
  11. int n, G;
  12. int main()
  13. {
  14.     while(cin>>n && n != 0){
  15.         for(int i = 1; i < n; i++)
  16.             for(int j = i + 1; j <= n;j++){
  17.                 G+=GCD(i,j);
  18.             }
  19.         cout<<G<<endl;
  20.         G = 0;
  21.     }
  22.     return 0;
  23. }
Add Comment
Please, Sign In to add comment