Help to create a program in JAVA that accepts an integer, displays all prime numbers from zero to the received number. Using only simple if and for operations I compiled, but something does not help import java.util.Scanner;
public class prostue_chisla { public static void main(String[] args) { System.out.println("Введите положительное число: "); Scanner in = new Scanner(System.in); int input = in.nextInt(); boolean b = true; for (int P = 1; P <= input; P++) { for (int i = 1; i < P; i++) { if (P % i == 0){ b = false; } System.out.println(P);} } } }
bvariable? What exactly is wrong in the above code? - ArchDemon