Created
September 22, 2016 15:12
-
-
Save devetude/1670a0db6d9ff3a1d4539f658f255c9b to your computer and use it in GitHub Desktop.
소수판별 2 (Check Prime Number 2)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Scanner; | |
/** | |
* 소수판별 2 (Check Prime Number 2) | |
* | |
* @author devetue | |
*/ | |
public class Main { | |
public static void main(String args[]) { | |
Scanner sc = new Scanner(System.in); | |
int N = sc.nextInt(); | |
sc.close(); | |
int res = -1; | |
int sqrtN = (int) Math.sqrt(N); | |
for (int i = 2; i < sqrtN; i++) { | |
if (N % i == 0) { | |
res = i; | |
break; | |
} | |
} | |
if (res != -1 || N == 1) { | |
System.out.println(N + " isn't prime number"); | |
} | |
else { | |
System.out.println(N + " is prime number "); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment