Skip to content

Commit 6cda825

Browse files
authored
Create Three Divisors.java
1 parent d876bca commit 6cda825

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

Easy/Three Divisors.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
class Solution {
2+
public boolean isThree(int n) {
3+
int numOfDivisors = 0;
4+
for (int i = 1; i <= n; i++) {
5+
if (n % i == 0) {
6+
numOfDivisors++;
7+
}
8+
if (numOfDivisors > 3) {
9+
return false;
10+
}
11+
}
12+
return numOfDivisors == 3;
13+
}
14+
}

0 commit comments

Comments
 (0)