Advertisement
Guest User

Untitled

a guest
Feb 25th, 2017
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.40 KB | None | 0 0
  1. #include<iostream>
  2. using namespace std;
  3.  
  4. int main()
  5. {
  6.     long long int suma=0;
  7.     bool klawa[2000000];
  8.     for(long long int i=2;i<2000000;i++)
  9.     {
  10.         klawa[i]=1;
  11.     }
  12.     for(int i=2;i<1415;i++)
  13.     {
  14.         if(klawa[i]==1)
  15.         {
  16.             for(int j=i*i;j<2000000;j+=i)
  17.             {
  18.                 klawa[j]=0;
  19.             }
  20.         }
  21.     }
  22.     for(long long int i=2;i<2000000;i++)
  23.     {
  24.         if(klawa[i]==1)
  25.         {
  26.         suma+=i;   
  27.     }
  28.     }
  29.     cout<<suma;
  30.     return 0;
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement