Pagini recente » Cod sursa (job #2393349) | Cod sursa (job #1573158) | Cod sursa (job #2659098) | Cod sursa (job #868545) | Cod sursa (job #138751)
Cod sursa(job #138751)
#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;}