Skip to content

Instantly share code, notes, and snippets.

@invatainfo
Last active January 29, 2018 16:48
#include <iostream>
using namespace std;
long cmmdc(long a, long b) {
while (a != b)
if (a > b)
a = a - b;
else
b = b - a;
return a;
}
int main() {
int n, a, b, nr = 0;
cin >> n;
for (a = 2; a < n; a++)
for (b = a + 1; b <= n; b++)
if (cmmdc(a,b) == 1)
nr++;
cout << nr;
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment