Just another update
This commit is contained in:
parent
a25938f123
commit
00a190b0a6
6591 changed files with 94363 additions and 23227 deletions
|
|
@ -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
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue