Created
February 27, 2014 15:32
-
-
Save Ninjex/9252371 to your computer and use it in GitHub Desktop.
Hailstorm Function
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
#!/usr/bin/ruby | |
def hailstorm n | |
vals = [n] | |
while n > 1 and n = (n.even?) ? (n/2) : (3 * n + 1) | |
vals << n | |
end | |
p vals # List returns | |
end | |
hailstorm(27) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment