{{uploading-image-751712.png(uploading...)}}
- 对n不断除以5,3,2,最后看是否能除尽(即最后等于1)
func isUgly(n int) bool {
if n<=0{
return false
}
if n==1{
return true
}
for n%5==0{
n/=5
}
for n%3==0{
n/=3
}
for n%2==0{
n/=2
}
return n==1
}