Pagini recente » Cod sursa (job #812237) | Cod sursa (job #2323091) | Cod sursa (job #1113698) | Cod sursa (job #1779941) | Cod sursa (job #138750)
Cod sursa(job #138750)
#include<iostream.h>
#include<stdio.h>
int main ()
{long int P=2,Q,N;
int contor,truth=1,truth2=3;
freopen ("fractii.in", "rt" ,stdin);
freopen ("fractii.out","wt" ,stdout);
scanf ("%ld", &N);
if (N==1) printf ("%d",truth);
else if (N==2) printf ("%d",truth2);
else {for (contor=2*N-1;P<=N;P++)
{Q=2;
while (Q<=N) {if (P%Q!=0) contor++;
else if (Q%P!=0) contor++;
Q++;}}
printf ("%d",contor);}
return 0;}