Skip to content

Instantly share code, notes, and snippets.

@Ninjex
Created February 27, 2014 15:32
Show Gist options
  • Save Ninjex/9252371 to your computer and use it in GitHub Desktop.
Save Ninjex/9252371 to your computer and use it in GitHub Desktop.
Hailstorm Function
#!/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