-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathSumofprime.c
55 lines (48 loc) · 864 Bytes
/
Sumofprime.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#include<stdio.h>
void main()
/*{
int n,t,i,sum,c;
scanf("%d",&t);
for(i=0;i<=n;i++)
{
scanf("%d",&n);
if(n%i==0)
{
c++;
}
if(c==2)
{
sum +=n;
}
printf("%d is sum of prime number",sum);
}
}*/
int isprime(int n){
for(int i=2; i<=((int)(pow(n, 0.5))); i++){
if(n%i==0){
return 0;
}
}
return 1;
}
int main()
{
int t;
scanf("%d", &t);
int inp[t];
for(int i=0; i<t; i++){
scanf("%d", &(inp[i]));
fflush(stdin);
}
int sum = 0;
for(int i=0; i<t; i++){
for(int j=2; j<inp[i]; j++){
if(isprime(j)){
sum += j;
}
}
printf("%d\n", sum);
sum = 0;
}
return 0;
}