Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- import java.util.Arrays;
- class Main {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- int n = Integer.parseInt(scanner.nextLine());
- int[] numbers = new int[n];
- Arrays.setAll(numbers, p -> p >= n ? 0 : p + 1);
- for (int number : numbers) {
- boolean isPrime = number > 1;
- for (int i = 2; i <= Math.sqrt(number); i++) {
- if (number % i == 0) {
- isPrime = false;
- break;
- }
- }
- if (isPrime) {
- System.out.print(number + " ");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement