import java.util.Scanner;
public class PJJJeden {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.print("wpisz wartosc a: ");
int a = sc.nextInt();
int dzielnik = 0;
for(int i = 1; i <= a; i++){
if(a%i == 0) {
dzielnik++;
}
}
if (dzielnik <= 2) {
System.out.println("liczba pierwsza");
}
else{
System.out.println("liczba nie jest pierwsza");
}
}
}
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter