Merge pull request #119 from NovaHe/fix/263

fix 263: remove redundant compute
This commit is contained in:
halfrost
2021-05-01 01:41:32 +08:00
committed by YDZ
2 changed files with 11 additions and 6 deletions

View File

@ -1,9 +1,11 @@
package leetcode
func isUgly(num int) bool {
for i := 2; i < 6 && num > 0; i++ {
for num%i == 0 {
num /= i
if num > 0 {
for _, i := range []int{2, 3, 5} {
for num%i == 0 {
num /= i
}
}
}
return num == 1