Pagini recente » Cod sursa (job #2184617) | Cod sursa (job #1336241) | Cod sursa (job #1075244) | Cod sursa (job #1351568) | Cod sursa (job #1213541)
#include<iostream>
#include<fstream>
using namespace std;
ifstream in("fractii.in");
ofstream out("fractii.out");
int prime(int p, int q){
if(p<q)
swap(p,q);
if(p%q==0)
return 0;
int i;
for(i=2;i<=q;i++)
if(p%i==0 && q%i==0)
return 0;
return 1;
}
int main(){
int n,p,q,s=0;
in>>n;
in.close();
s=n*n;
for(p=2;p<=n;p++)
for(q=2;q<=n;q++)
if(!prime(p,q))
s--;
out<<s<<"\n";
out.close();
return 0;
}