Skip to content

Instantly share code, notes, and snippets.

@spreered
Last active September 13, 2017 07:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save spreered/1ac7604ea1dba0024917683e71c79678 to your computer and use it in GitHub Desktop.
Save spreered/1ac7604ea1dba0024917683e71c79678 to your computer and use it in GitHub Desktop.
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