Pagini recente » Cod sursa (job #930208) | Cod sursa (job #973274) | Cod sursa (job #2987184) | Cod sursa (job #1120620) | Cod sursa (job #1327862)
#include <cstdio>
using namespace std;
char prim[1000000];
void ciur(int n){
int i,j;
int multiplii;
unsigned long long nr=2*n-1;
for (i=2;i<=n;i++)
prim[i]=1;
for (i=2;i<=n;i++){
if (prim[i]){
multiplii=0;
for (j=i+i;j<=n;j=j+i){
multiplii++;
prim[j]=0;}
if (multiplii){
nr=nr+(n-multiplii);} else {
nr=nr+(n-1);
}
}
}
printf ("%d", nr-2);
}
int main()
{
freopen ("fractii.in", "r", stdin);
freopen ("fractii.out", "w", stdout);
int n,i;
scanf ("%d", &n);
if (n==1){
printf ("%d", 1);}
if (n==2){
printf ("%d", 3);}
else if (n!=1&&n!=2){
ciur(n);}
return 0;
}