-
-
Save spreered/1ac7604ea1dba0024917683e71c79678 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def is_ugly(num) | |
return false if num <= 0 | |
return true if num == 1 | |
[2,3,5].each do |i| | |
while num % i == 0 | |
num = num / i | |
end | |
end | |
return num == 1 | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment