Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 12 additions & 21 deletions 2019 Ready Set Code/Round-1/1/Solution.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,19 @@

public class Solution {

static boolean prime(int n) {
int c, i;
c = 0;
for (i = 2; i < Math.sqrt(n); i++) {
if (n%i == 0) {
c++;
}
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int a = sc.nextInt();
int f = 0;
for(int i = 1 ; i <= a ; i++) {
if(a%i == 0)
f++;
}
return c == 0;
}
public static void main(String args[]) {
Scanner scanner = new Scanner(System.in);
int n = scanner.nextInt();
if (n <= 1) {
if(f == 2)
System.out.println("PRIME");
else if(f == 1 || a == 0)
System.out.println("NONE");
} else {
if(prime(n)) {
System.out.println("PRIME");
} else {
System.out.println("NOT PRIME");
}
}
scanner.close();
else
System.out.println("NOT PRIME");
}
}