Fibonacci Series in Powershell

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,$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.


4 Responses to “Fibonacci Series in Powershell”

  1. /\/\o\/\/ Says:

    for the Morris series in PowerShell:

    Greetings /\/\o\/\/

  2. spiritual business Says:

    spiritual business…

    […]Fibonacci Series in Powershell « Get-Powershell[…]…

  3. Jill Says:

    Hello, i read your blog from time to time and i
    own a similar one and i was just curious if you get a lot of spam responses?
    If so how do you protect against it, any plugin or anything you can recommend?

    I get so much lately it’s driving me insane so any assistance is very much appreciated.

  4. kick ass Torrents Says:

    I know this if off topic but I’m looking into starting my own blog and was wondering what all is required to get setup? I’m
    assuming having a blog like yours would cost a pretty penny?
    I’m not very web smart so I’m not 100% certain. Any tips or advice would be greatly appreciated.

    Many thanks

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: