Skip to content

Commit a4cc4fe

Browse files
EASY/src/easy/UglyNumber.java
1 parent f1aafad commit a4cc4fe

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

EASY/src/easy/UglyNumber.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package easy;
2+
3+
public class UglyNumber {
4+
5+
public boolean isUgly(int num) {
6+
if(num == 0) return false;
7+
int[] divisors = new int[]{5,3,2};
8+
for(int divisor : divisors){
9+
while(num%divisor == 0){
10+
num /= divisor;
11+
}
12+
}
13+
return num == 1;
14+
}
15+
16+
}

0 commit comments

Comments
 (0)