Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
From One End to the Other
# From One End to the Other: Find the smallest possible
# (positive) integer that ends in a six such that if that six is removed and
# placed in front of the remaining digits of the number, the resulting number
# will be four times as large as the original.
i = 6
loop do
digits = i.to_s.split('')
if digits.last == '6' && digits.rotate(-1).join.to_i == (i * 4)
puts i
break
end
i = i + 2
end
# 153846
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.