🔍Prime Number 추출하기
int[] arr = { 0,1,2,3,4,5,6,7,8,9 };
✏️Solution
int[] arr = { 0,1,2,3,4,5,6,7,8,9 };
for(int index = 0; index < arr.length; index++) {
int number = arr[index];
switch(number) {
case 0,1 -> {;;}
default -> {
boolean isPrimeNumber = true;
for(int s = 2; s < number; s++) {
if(number % s == 0) {
isPrimeNumber = false;
break;
}
}
if(isPrimeNumber) {
System.out.println(number);
}
} // default
} // switch
}// for