Last active
March 6, 2016 23:49
-
-
Save jwworth/5a5b3647a44b9a782896 to your computer and use it in GitHub Desktop.
From One End to the Other
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
# 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