Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ///Summation of prime number
- #include<bits/stdc++.h>
- using namespace std;
- long prime(long n)
- {
- long sum=0;
- int i,j;
- for(i=2;i<=n;i++)
- {
- int f = 0;
- if(i==2)
- {
- sum = sum+2;
- continue;
- f++;
- }
- for(j=2;j<=i/2;j++)
- {
- if(i%j==0)
- {
- f =1;
- break;
- }
- }
- if(f==0)
- sum = sum+i;
- }
- return sum;
- }
- int main()
- {
- long t,i;
- long n,*sum,*temp;
- cin>>t;
- sum = new long;
- temp = sum;
- for(i=0;i<t;i++)
- {
- cin>>n;
- *sum = prime(n);
- sum++;
- }
- for(i=0;i<t;i++)
- {
- if(*temp==1)
- continue;
- cout<<*temp<<endl;
- temp++;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement