LeetCode之263. Ugly Number

-------------------------------------------------------------

如果一个数的质因子只包括2,3,5,那么这个数n可以表示为:
n=2x+3y+5z

AC代码:

import java.math.BigInteger;

public 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;
    }
    
}

题目来源: https://leetcode.com/problems/ugly-number/

原文地址:https://www.cnblogs.com/cc11001100/p/6003373.html