-
-
Save Rojo/2a7518664d3b56e99239 to your computer and use it in GitHub Desktop.
Para los números del 0 al 999, realizar la suma de los cubos de los digitos que los componen.
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
# abc=a^3+b^3+c^3 | |
i = 0 | |
max = 999 | |
while i <=999 | |
puts i.to_s.rjust(3,'0') if i == ((i /100) ** 3) + ((i % 100 / 10) ** 3) + ((i % 10) ** 3) | |
i +=1 | |
end | |
=> | |
000 | |
001 | |
153 | |
370 | |
371 | |
407 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment