楼主:
Rushia (みけねこ的鼻屎)
2022-11-18 09:31:45263. Ugly Number
如果一个数字只由2、3、5组成因子他是一个丑数,判断数字n是否是丑数。
Input: n = 6
Output: true
Explanation: 6 = 2 × 3
Example 2:
Input: n = 1
Output: true
Explanation: 1 has no prime factors, therefore all of its prime factors are
limited to 2, 3, and 5.
思路:
1.若n=0直接返回false。
2.不断的把n除2、3、5,并判断除到不能再除的时候n是否为1即可。
JavaCode: