Pagini recente » Cod sursa (job #717083) | Cod sursa (job #1068394) | Cod sursa (job #2818748) | Cod sursa (job #300153) | Cod sursa (job #1249515)
#include <stdio.h>
#include <stdlib.h>
char v[1000111];
int n, x, i, y, j;
long long int s;
int main()
{
freopen("sum.in", "r", stdin);
freopen("sum.out", "w", stdout);
scanf("%d", &n);
for(i = 0; i < n; i++)
{
s = 1;
scanf("%d", &x);
for(y = 2; y <= 2*x; y++)
v[y] = 1;
for(y = 2; y <= 2*x; y++)
if(x % y == 0)
v[y] = 0;
for(y = 2; y <= 2*x; y++)
{
if(v[y] == 0)
{
for(j = y+y; j <= 2*x; j += y)
v[j] = 0;
}
}
for(y = 2; y <= 2*x; y++)
if(v[y])
{
s += y;
}
printf("%lld\n", s);
}
return 0;
}