Skip to content

Commit f90a5a3

Browse files
Create 0263-ugly-number.java
1 parent 2d0e0cc commit f90a5a3

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

Diff for: java/0263-ugly-number.java

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
class Solution {
2+
public boolean isUgly(int n) {
3+
if(n <= 0)
4+
return false;
5+
6+
for(int p: new int[] {2, 3, 5})
7+
while(n % p == 0)
8+
n = n / p;
9+
return n == 1;
10+
}
11+
}

0 commit comments

Comments
 (0)