package prima;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner
input = new Scanner(System.in);
boolean isPrima;
int x = 2;
int count = 1;
System.out.print("Masukkan banyak
angka : ");
int angka = input.nextInt();
while(count <= angka){
isPrima=false;
if(x == 2 || x == 3 || x == 5){
isPrima = true;
}
else if(x % 2 != 0){
if(x % 3 != 0){
if(x % 5 != 0){
isPrima = true;
}
}
}
if(isPrima==true){
System.out.print(x+"
");
count++;
}
x++;
}
System.out.println("\n");
}
}
Tidak ada komentar:
Posting Komentar