Pagini recente » Cod sursa (job #1879763) | Cod sursa (job #2945719) | tema | Cod sursa (job #2219320) | Cod sursa (job #1996433)
#include<iostream>
#include<fstream>
#include<math.h>
using namespace std;
bool nrPrimeIntreEle(int a, int b);
int main(){
int count = 0;
int n = 0;
ifstream inFile;
inFile.open("fractii.in.txt");
ofstream outFile;
outFile.open("fractii.out.txt");
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;
}
}