Fibonacci Series in Powershell
January 24, 2008 at 5:01 PM
—
Andy Schneider
Scott Hanselman recently posted
The Weekly Source 13 - Fibonacci Edition. . It was a very interesting read, but it was missing the Powershell version.
As in the Ruby example, you can use multiple assignments in Powershell as well
Function Get-Fib ($n) {
$current = $previous = 1;
while ($current -lt $n) {
$current;
$current,$previous = ($current + $previous),$current}
}
Get-Fib 100
Bruce's book,
Powershell in Action, uses a slightly more terse version of this function in his discussion of multiple variable assignment.
b0124513-7815-48d0-8a05-74b29398e616|0|.0
Posted in:
Tags: