# 3桁の数で割り切れるかチェック
def checkDivided(num)
min = 111
max = 999
# 3桁の積でないものは弾く
return false if num < min ** 2 && num > max ** 2
# minから順に割っていき、割り切れる&商が3桁ならtrue
min.upto(max) do |x|
if num % x == 0 && (num / x).to_s.length == 3
return true
end
end
return false
end
More than 5 years have passed since last update.
Register as a new user and use Qiita more conveniently
- You get articles that match your needs
- You can efficiently read back useful information
- You can use dark theme
List of users who liked
33