Guest User

Untitled

a guest
Mar 22nd, 2018
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 KB | None | 0 0
  1. import java.util.*;
  2.  
  3. class Solution {
  4. public static void main(String[] args) {
  5. Boolean[] prime = new Boolean[1000001];
  6. for (int a = 2; a <= 1000000; a++) {
  7. prime[a] = true;
  8. }
  9. for (int a = 2; a <= 1000; a++) {
  10. if(prime[a]) {
  11. for(int b=2;a*b<=1000000;b++) {
  12. prime[a*b]=false;
  13. }
  14. }
  15. }
  16. for (int a = 2; a <= 1000000; a++) {
  17. if(prime[a]) {
  18. System.out.print(a+" ");
  19. }
  20. }
  21. // Scanner sc = new Scanner(System.in);
  22. // int t = sc.nextInt();
  23. // for (int a = 1; a <= t; a++) {
  24. // System.out.println("#" + z + " " + x + " " + y);
  25. // }
  26. // sc.close();
  27. }
  28. }
Add Comment
Please, Sign In to add comment