Last active
December 20, 2015 02:58
-
-
Save roshkins/6059726 to your computer and use it in GitHub Desktop.
My four line solution for reversing a number.
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
def reverse(num) | |
return num if num < 10 | |
return (num % 10) * 10 ** Math.log10(num).floor + reverse(num/10) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment