Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.*;
- class Solution {
- public static void main(String[] args) {
- Boolean[] prime = new Boolean[1000001];
- for (int a = 2; a <= 1000000; a++) {
- prime[a] = true;
- }
- for (int a = 2; a <= 1000; a++) {
- if(prime[a]) {
- for(int b=2;a*b<=1000000;b++) {
- prime[a*b]=false;
- }
- }
- }
- for (int a = 2; a <= 1000000; a++) {
- if(prime[a]) {
- System.out.print(a+" ");
- }
- }
- // Scanner sc = new Scanner(System.in);
- // int t = sc.nextInt();
- // for (int a = 1; a <= t; a++) {
- // System.out.println("#" + z + " " + x + " " + y);
- // }
- // sc.close();
- }
- }
Add Comment
Please, Sign In to add comment