Pagini recente » Cod sursa (job #1055546) | Istoria paginii monthly-2012/runda-10 | Cod sursa (job #1569385) | Monitorul de evaluare | Cod sursa (job #241664)
Cod sursa(job #241664)
#include <iostream>
#include <fstream>
using namespace std;
int main() {
int n;
int p;
int q;
int nrfractii=0;
bool ireductibila;
int k;
ifstream f;
ofstream g;
f.open("fractii.in");
g.open("fractii.out");
f>>n;
for(p=1; p<=n; p++) {
for(q=1; q<=n; q++) {
ireductibila=true;
if(p==1 || q==1) {
ireductibila=true;
}
else {
for(k=2; k<=p; k++) {
if(p%k==0 && q%k==0) {
ireductibila=false;
}
}
}
if(ireductibila) {
nrfractii++;
}
}
}
g<<nrfractii;
f.close();
g.close();
return 0;
}