Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include<math.h>
- using namespace std;
- const unsigned N = 1000;
- int main()
- {
- bool T[N+1];
- unsigned i,w,g;
- for(i=2;i<=N;i++) T[i]=true;
- g=sqrt(N);
- for(i=2;i<=g;i++)
- if(T[i]) for(w= i * i; w<=N;w +=i) T[w]=false;
- int y;
- int x;
- cout<<"PODAJ X: ";
- cin>>x;
- for(i=2;i<=x;i++)
- {
- if(T[i])
- for(y =2 ;y<=x;y ++)
- {
- if(y!=i)
- if(y%i==0)
- {
- cout<<y<<endl;
- }
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement