题目描述
https://leetcode-cn.com/problems/ugly-number/
解
func isUgly(num int) bool {
for {
if num == 1 {
return true
}
switch {
case num%2 == 0:
num /= 2
case num%3 == 0:
num /= 3
case num%5 == 0:
num /= 5
default:
return false
}
}
}
思路
丑数我依旧认为这个是最优美的版本了,可是这个版本没有三个if判断的得分高!
网友评论