Guest User

Untitled

a guest
Jan 11th, 2019
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.70 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstring>
  3. using namespace std;
  4.  
  5. bool prime[10000000];
  6.  
  7. void eratostene()
  8. {
  9.     long long unsigned int i,j;
  10.     long long unsigned int r;
  11.     for(i=1;i<=100000;++i)
  12.     {
  13.         if(prime[i] == 0)
  14.         {
  15.             j = (i<<1)+1;
  16.             for(r = j*j;r<=1000000;r+=(j<<1))
  17.                 prime[(r-1)>>1]=1;
  18.         }
  19.     }
  20. }
  21.  
  22. int main()
  23. {
  24.     int a,b;
  25.     //cin >> a >> b;
  26.     int i;
  27.     int prim=0;
  28.     long long unsigned x;
  29.     eratostene();
  30.     cout << prime[4];
  31.     /*
  32.     x = a*a+a+41;
  33.     cout << prim;
  34.     for(i=a;i<=b;++i)
  35.     {
  36.         if(prime[(x-1)>>1] == 0)
  37.             ++prim;
  38.         x += (i+1)<<1;
  39.     }
  40.     */
  41.     return 0;
  42. }
Add Comment
Please, Sign In to add comment