Advertisement
Guest User

Untitled

a guest
Sep 21st, 2017
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  1. #include <iostream>
  2. #include<math.h>
  3.  
  4. using namespace std;
  5.  
  6. const unsigned N = 1000;
  7.  
  8. int main()
  9. {
  10. bool T[N+1];
  11. unsigned i,w,g;
  12.  
  13.  
  14. for(i=2;i<=N;i++) T[i]=true;
  15.  
  16. g=sqrt(N);
  17.  
  18. for(i=2;i<=g;i++)
  19. if(T[i]) for(w= i * i; w<=N;w +=i) T[w]=false;
  20.  
  21.  
  22. int y;
  23. int x;
  24. cout<<"PODAJ X: ";
  25. cin>>x;
  26. for(i=2;i<=x;i++)
  27. {
  28. if(T[i])
  29. for(y =2 ;y<=x;y ++)
  30. {
  31. if(y!=i)
  32. if(y%i==0)
  33. {
  34.  
  35. cout<<y<<endl;
  36. }
  37.  
  38.  
  39. }
  40.  
  41. }
  42.  
  43.  
  44.  
  45.  
  46.  
  47.  
  48. return 0;
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement