Skip to content

Commit

Permalink
263
Browse files Browse the repository at this point in the history
  • Loading branch information
jiangshanmeta committed Dec 25, 2024
1 parent c81cfb3 commit 20d68c9
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/0263.ugly-number.263/solution.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
class Solution {
public boolean isUgly(int n) {
if(n < 1){
return false;
}
while (n%2 == 0){
n /= 2;
}
while (n%3 == 0){
n /= 3;
}
while (n%5 == 0){
n /= 5;
}
return n == 1;
}
}

0 comments on commit 20d68c9

Please sign in to comment.