Created
August 23, 2016 02:11
-
-
Save mattmcnabb/432fd78dca1f54d173cfb301ad283c07 to your computer and use it in GitHub Desktop.
Blog_rosetta-code
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
function Get-HailStone | |
{ | |
param($n) | |
switch($n) { | |
{$_ -lt 1} {return} | |
1 {$n; return} | |
{$n % 2 -eq 0} {$n; return Get-Hailstone ($n = $n / 2)} | |
{$n % 2 -ne 0} {$n; return Get-Hailstone ($n = ($n * 3) +1)} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment