September 2017 Update

This commit is contained in:
Ingy döt Net 2017-09-23 10:01:46 +02:00
parent bba7bfd280
commit ba8067c3b7
14570 changed files with 153136 additions and 63871 deletions

View file

@ -0,0 +1,17 @@
#Create generator of extended fibonaci
Function Get-ExtendedFibonaciGenerator($InitialValues ){
$Values = $InitialValues
{
#exhaust initial values first before calculating next values by summation
if ($InitialValues.Length -gt 0) {
$NextValue = $InitialValues[0]
$Script:InitialValues = $InitialValues | Select -Skip 1
return $NextValue
}
$NextValue = $Values | Measure-Object -Sum | Select -ExpandProperty Sum
$Script:Values = @($Values | Select-Object -Skip 1) + @($NextValue)
$NextValue
}.GetNewClosure()
}

View file

@ -0,0 +1,10 @@
$Name = 'fibo tribo tetra penta hexa hepta octo nona deca'.Split()
0..($Name.Length-1) | foreach { $Index = $_
$InitialValues = @(1) + @(foreach ($I In 0..$Index) { [Math]::Pow(2,$I) })
$Generator = Get-ExtendedFibonaciGenerator $InitialValues
[PSCustomObject] @{
n = $InitialValues.Length;
Name = "$($Name[$Index])naci";
Sequence = 1..15 | foreach { & $Generator } | Join-String -Separator ','
}
} | Format-Table -AutoSize