Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- int gcd(int a, int b) {
- if (!b) return a;
- return gcd(b, a % b);
- }
- int main(){
- int n;
- while (cin >> n) {
- if (n == 0) break;
- int G = 0;
- for (int i = 1; i < n; i++) {
- for (int j = i + 1; j <= n; j++) {
- G = G + gcd(i, j);
- }
- }
- cout << G << endl;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement