Pagini recente » Cod sursa (job #1855297) | Cod sursa (job #846980) | Istoria paginii runda/asd/clasament | Cod sursa (job #750483) | Cod sursa (job #1996285)
#include<iostream>
#include<fstream>
using namespace std;
bool nrPrimeIntreEle(int a, int b);
int main(){
int count = 0;
unsigned int n;
ifstream inFile;
inFile.open("fractii.in.txt");
ofstream outFile;
outFile.open("fractii.out");
while (!inFile.eof()){
inFile >> n;
for (int i = 1; i <= n; i++){
for (int j = 1; j <= n; j++){
if (nrPrimeIntreEle(i, j)){
count++;
}
}
}
outFile << count << "\n";
count = 0;
}
outFile.close();
inFile.close();
return 0;
}
bool nrPrimeIntreEle(int a, int b){
while (a != b){
if (a > b){
a = a - b;
}
else{
b = b - a;
}
}
if (a == 1){
return true;
}
else{
return false;
}
}