본문 바로가기

JAVA

[JAVA] 소수 판별법

boolean isPrime=true;
for(int i=2; i<=num/2; i++){
    if(num%i==0){
        isPrime=false;
        break;
    }
}