Pagini recente » Cod sursa (job #1201131) | Cod sursa (job #1043497) | Cod sursa (job #2511163) | Cod sursa (job #2513517) | Cod sursa (job #2477406)
#include<fstream>
/*
* SORT HEAP
*/
int n;
int total = 0;
std::ifstream in("fractii.in");
std::ofstream out("fractii.out");
bool primes(int i, int j);
int main() {
in >> n;
for (int i = 1; i <= n; i++)
for (int j = 1; j <= n; j++) {
if (i != j)
if (i == 1 || j == 1) {
total++;
}
else if (primes(i, j)) {
total++;
}
}
out << total + 1;
}
bool primes(int i, int j) {
int t;
while (j != 0) {
t = i;
i = j;
j = t % j;
}
return i == 1;
}