Skip to content

Instantly share code, notes, and snippets.

@devetude
Created September 22, 2016 15:09
Show Gist options
  • Save devetude/f62de976bf7214c3da24fbf8f5438968 to your computer and use it in GitHub Desktop.
Save devetude/f62de976bf7214c3da24fbf8f5438968 to your computer and use it in GitHub Desktop.
소수판별 1 (Check Prime Number 1)
import java.util.Scanner;
/**
* 소수판별 1 (Check Prime Number 1)
*
* @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;
for (int i = 2; i < N; 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