Cod sursa(job #2246597)
Utilizator | Data | 27 septembrie 2018 11:34:10 | |
---|---|---|---|
Problema | Fractii | Scor | 0 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.69 kb |
#include <iostream>
using namespace std;
int main()
{ int n,p=1,q,c=0,d,ok;
cin>>n;
while(p<=n){
for(q=1;q<=n;q++){
ok=1;
if(q==1 && p==1){ c++;}
if(q!=p){
if(q>=p){
d=2;
while(d<=q/2){
if(q%d==0 && p%d==0) ok=0;
d++;
}}else{
d=2;
while(d<=p/2){
if(q%d==0 && p%d==0) ok=0;
d++;
}
}
if(ok==1) {c++;}
}
}
p++;
}
cout << c << endl;
return 0;
}