Skip to content

Instantly share code, notes, and snippets.

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
i = i + 2
# 153846
You can’t perform that action at this time.