Pagini recente » Cod sursa (job #2730677) | Cod sursa (job #1599230) | Cod sursa (job #1190388) | Cod sursa (job #3213286) | Cod sursa (job #189137)
Cod sursa(job #189137)
#include<fstream.h>
ifstream f("fractii.in");
ofstream g("fractii.out");
int main()
{
int i,S[100],j,k,r,l;
long int N;
f>>N;
f.close();
for(i=1;i<=N;i++)
S[i]=N;
for(i=2;i<=N;i++)
{
j=i;
k=1;
r=0;
while(j<=N)
{
j=i*k;
if(j>i) S[j]=S[j]-1;
k++;
if(j<=N) r++;
}
S[i]=S[i]-r;
}
l=0;
for(i=1;i<=N;i++)
{
l=l+S[i];
}
g<<l;
g.close();
return 0;
}