Just another update

This commit is contained in:
Ingy döt Net 2015-02-20 00:35:01 -05:00
parent a25938f123
commit 00a190b0a6
6591 changed files with 94363 additions and 23227 deletions

View file

@ -1,26 +1,27 @@
# Author M. McNabb
function Get-HailStone {
param($n)
switch($n) {
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)}
}
}
function Get-HailStoneBelowLimit {
param($UpperLimit)
begin {
function Get-HailStone {
param($n)
switch($n) {
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)}
}
param($UpperLimit)
$Counts = @()
for ($i = 1; $i -lt $UpperLimit; $i++) {
$Object = [pscustomobject]@{
'Number' = $i
'Count' = (Get-HailStone $i).count
}
$Counts = @()
$Counts += $Object
}
process {
for ($i = 1; $i -lt $UpperLimit; $i++) {
$Object = [pscustomobject]@{
'Number' = $i
'Count' = (Get-HailStone $i).count
}
$Counts += $Object
}
}
end {$Counts}
$Counts
}