diff --git a/com.leetcode.test/java/04-10.java b/com.leetcode.test/java/04-10.java index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..5ac8a109fd30be7c010ee1dfa6e02d4a4d0d892f 100644 --- a/com.leetcode.test/java/04-10.java +++ b/com.leetcode.test/java/04-10.java @@ -0,0 +1,18 @@ +class Solution { + public boolean isUgly(int n) { + + if(n<1){ + return false; + } + + int[] primes = {2,3,5}; + + for(int i:primes){ + while(n%i == 0){ + n /= i; + } + } + + return n == 1; + } +} \ No newline at end of file