<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Huddled Masses &#187; Fibonacci</title>
	<atom:link href="http://huddledmasses.org/tag/fibonacci/feed/" rel="self" type="application/rss+xml" />
	<link>http://huddledmasses.org</link>
	<description>You can do more than breathe for free...</description>
	<lastBuildDate>Sat, 28 Jan 2012 21:37:20 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
<cloud domain='huddledmasses.org' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
		<item>
		<title>Recursion in PowerShell &#8230; slow</title>
		<link>http://huddledmasses.org/recursion-in-powershell-slow/</link>
		<comments>http://huddledmasses.org/recursion-in-powershell-slow/#comments</comments>
		<pubDate>Mon, 04 Feb 2008 06:12:20 +0000</pubDate>
		<dc:creator>Joel 'Jaykul' Bennett</dc:creator>
				<category><![CDATA[Huddled]]></category>
		<category><![CDATA[Fibonacci]]></category>
		<category><![CDATA[Performance]]></category>
		<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[Recursion]]></category>
		<category><![CDATA[Scripting]]></category>
		<category><![CDATA[Timing]]></category>

		<guid isPermaLink="false">http://HuddledMasses.org/recursion-in-powershell-slow/</guid>
		<description><![CDATA[So, I posted a story about Fibonacci sequences and noticed that the recursion in PowerShell is really rather slow. But I also noticed something interesting &#8212; I had expected that recursing using a function would be a little cheaper (and faster) than recursing using the pipeline, and it turns out that it&#8217;s not. At all. [...]]]></description>
			<content:encoded><![CDATA[	<p>So, I posted <a href="http://huddledmasses.org/fibbonaci-sequence-in-powershell/">a story about Fibonacci sequences</a> and noticed that the recursion in PowerShell is really rather slow. But I also noticed something interesting &#8212; I had expected that recursing using a function would be a little cheaper (and faster) than recursing using the pipeline, and it turns out that it&#8217;s not. At all.  </p>

	<p>I&#8217;d love to hear some thoughts on why I got the speed results I got here.  At first I thought it was something about type coercion, but as you can see, I tried casting everything to no avail.  There&#8217;s no difference if I don&#8217;t output anything, and in fact, the non-recursive algorithm can trivially output every Fibonacci number in the sequence without affecting it&#8217;s time (I actually altered it so it didn&#8217;t to keep the output clean).</p>

	<p>Obviously I expected the recursive algorithms to be slow and scale badly because of the amount of work involved, but how is it that the pipeline-recursive &#8220;filter&#8221; outperforms the plain old recursive function (albeit by an infinitesimal fraction)?</p>

	<div class="posh code posh" style="font-family:monospace;"><br />
<span style="color: #333;">&#91;</span>08<span style="color: #333;">&#93;</span>: <span style="color: #666699; font-weight: bold;">function</span> fibfunction<span style="color: #333;">&#40;</span><span style="color: #003366; font-weight: bold;"><span style="color: #333;">&#91;</span><span style="color: #003366; font-weight: bold;">int</span><span style="color: #333;">&#93;</span></span><span style="color: #660033; font-weight: bold;">$i</span><span style="color: #333;">&#41;</span><span style="color: #333;">&#123;</span> <span style="color: #666699; font-weight: bold;">if</span><span style="color: #333;">&#40;</span><span style="color: #660033; font-weight: bold;">$i</span> <span style="color: #000066;">-lt</span> <span style="color: #cc66cc;">2</span><span style="color: #333;">&#41;</span> <span style="color: #333;">&#123;</span> <span style="color: #cc66cc;">1</span> <span style="color: #333;">&#125;</span><span style="color: #666699; font-weight: bold;">else</span><span style="color: #333;">&#123;</span> <span style="color: #003366; font-weight: bold;"><span style="color: #333;">&#91;</span><span style="color: #003366; font-weight: bold;">int</span><span style="color: #333;">&#93;</span></span><span style="color: #333;">&#40;</span>fibfunction <span style="color: #333;">&#40;</span><span style="color: #660033; font-weight: bold;">$i</span><span style="color: #66cc66;">-</span><span style="color: #cc66cc;">1</span><span style="color: #333;">&#41;</span><span style="color: #333;">&#41;</span> <span style="color: #66cc66;">+</span> <span style="color: #003366; font-weight: bold;"><span style="color: #333;">&#91;</span><span style="color: #003366; font-weight: bold;">int</span><span style="color: #333;">&#93;</span></span><span style="color: #333;">&#40;</span>fibfunction <span style="color: #333;">&#40;</span><span style="color: #660033; font-weight: bold;">$i</span><span style="color: #66cc66;">-</span><span style="color: #cc66cc;">2</span><span style="color: #333;">&#41;</span><span style="color: #333;">&#41;</span> <span style="color: #333;">&#125;</span> <span style="color: #333;">&#125;</span><br />
<br />
<span style="color: #333;">&#91;</span>09<span style="color: #333;">&#93;</span>: <span style="color: #666699; font-weight: bold;">filter</span> fibfilter<span style="color: #333;">&#123;</span> <span style="color: #666699; font-weight: bold;">if</span><span style="color: #333;">&#40;</span><span style="color: #660033; font-weight: bold;">$_</span><span style="color: #66cc66;">-</span>lt2<span style="color: #333;">&#41;</span><span style="color: #333;">&#123;</span><span style="color: #cc66cc;">1</span><span style="color: #333;">&#125;</span><span style="color: #666699; font-weight: bold;">else</span><span style="color: #333;">&#123;</span><span style="color: #003366; font-weight: bold;"><span style="color: #333;">&#91;</span><span style="color: #003366; font-weight: bold;">int</span><span style="color: #333;">&#93;</span></span><span style="color: #333;">&#40;</span><span style="color: #003366; font-weight: bold;"><span style="color: #333;">&#91;</span><span style="color: #003366; font-weight: bold;">int</span><span style="color: #333;">&#93;</span></span><span style="color: #660033; font-weight: bold;">$_</span><span style="color: #66cc66;">-</span><span style="color: #cc66cc;">1</span><span style="color: #66cc66;">|</span>fibfilter<span style="color: #333;">&#41;</span><span style="color: #66cc66;">+</span><span style="color: #003366; font-weight: bold;"><span style="color: #333;">&#91;</span><span style="color: #003366; font-weight: bold;">int</span><span style="color: #333;">&#93;</span></span><span style="color: #333;">&#40;</span><span style="color: #003366; font-weight: bold;"><span style="color: #333;">&#91;</span><span style="color: #003366; font-weight: bold;">int</span><span style="color: #333;">&#93;</span></span><span style="color: #660033; font-weight: bold;">$_</span><span style="color: #66cc66;">-</span><span style="color: #cc66cc;">2</span><span style="color: #66cc66;">|</span>fibfilter<span style="color: #333;">&#41;</span><span style="color: #333;">&#125;</span><span style="color: #333;">&#125;</span><br />
<br />
<span style="color: #333;">&#91;</span><span style="color: #cc66cc;">10</span><span style="color: #333;">&#93;</span>: <span style="color: #003366; font-weight: bold;"><span style="color: #333;">&#91;</span><span style="color: #003366; font-weight: bold;">int</span><span style="color: #333;">&#93;</span></span><span style="color: #660033; font-weight: bold;">$size</span> <span style="color: #66cc66;">=</span> <span style="color: #cc66cc;">18</span><br />
<span style="color: #333;">&#91;</span><span style="color: #cc66cc;">11</span><span style="color: #333;">&#93;</span>: fibfunction <span style="color: #660033; font-weight: bold;">$size</span><br />
<span style="color: #cc66cc;">4181</span><br />
<span style="color: #333;">&#91;</span><span style="color: #cc66cc;">12</span><span style="color: #333;">&#93;</span>: <span style="color: #660033; font-weight: bold;">$size</span> <span style="color: #66cc66;">|</span> fibfilter<br />
<span style="color: #cc66cc;">4181</span><br />
<span style="color: #333;">&#91;</span><span style="color: #cc66cc;">13</span><span style="color: #333;">&#93;</span>: <span style="color: #003366; font-weight: bold;"><span style="color: #333;">&#91;</span><span style="color: #003366; font-weight: bold;">int</span><span style="color: #333;">&#93;</span></span><span style="color: #660033; font-weight: bold;">$a</span>,<span style="color: #003366; font-weight: bold;"><span style="color: #333;">&#91;</span><span style="color: #003366; font-weight: bold;">int</span><span style="color: #333;">&#93;</span></span><span style="color: #660033; font-weight: bold;">$b</span> <span style="color: #66cc66;">=</span> <span style="color: #cc66cc;">0</span>,<span style="color: #cc66cc;">1</span>; 0..<span style="color: #660033; font-weight: bold;">$size</span><span style="color: #66cc66;">|%</span><span style="color: #333;">&#123;</span><span style="color: #660033; font-weight: bold;">$a</span>,<span style="color: #660033; font-weight: bold;">$b</span> <span style="color: #66cc66;">=</span> <span style="color: #333;">&#40;</span><span style="color: #660033; font-weight: bold;">$a</span><span style="color: #66cc66;">+</span><span style="color: #660033; font-weight: bold;">$b</span><span style="color: #333;">&#41;</span>,<span style="color: #660033; font-weight: bold;">$a</span><span style="color: #333;">&#125;</span>; <span style="color: #660033; font-weight: bold;">$a</span><br />
<span style="color: #cc66cc;">4181</span><br />
<span style="color: #333;">&#91;</span><span style="color: #cc66cc;">14</span><span style="color: #333;">&#93;</span>: <span style="color: #0066cc; font-style: italic;">get-<span style="font-style: normal;">history</span></span> <span style="color: #000066;">-count</span> <span style="color: #cc66cc;">3</span> <span style="color: #66cc66;">|</span> <span style="color: #660033;">fl</span> CommandLine,@<span style="color: #333;">&#123;</span>l<span style="color: #66cc66;">=</span><span style="color: #009900;">&quot;Duration&quot;</span>; e<span style="color: #66cc66;">=</span><span style="color: #333;">&#123;</span><span style="color: #660033; font-weight: bold;">$_</span>.<span style="color: #003366;">EndExecutionTime</span> <span style="color: #66cc66;">-</span> <span style="color: #660033; font-weight: bold;">$_</span>.<span style="color: #003366;">StartExecutionTime</span><span style="color: #333;">&#125;</span><span style="color: #333;">&#125;</span><br />
<br />
CommandLine : fibfunction <span style="color: #660033; font-weight: bold;">$size</span><br />
Duration &nbsp; &nbsp;: 00:00:<span style="color: #cc66cc;">02.4764040</span><br />
<br />
CommandLine : <span style="color: #660033; font-weight: bold;">$size</span> <span style="color: #66cc66;">|</span> fibfilter<br />
Duration &nbsp; &nbsp;: 00:00:<span style="color: #cc66cc;">02.2137255</span><br />
<br />
CommandLine : <span style="color: #003366; font-weight: bold;"><span style="color: #333;">&#91;</span><span style="color: #003366; font-weight: bold;">int</span><span style="color: #333;">&#93;</span></span><span style="color: #660033; font-weight: bold;">$a</span>,<span style="color: #003366; font-weight: bold;"><span style="color: #333;">&#91;</span><span style="color: #003366; font-weight: bold;">int</span><span style="color: #333;">&#93;</span></span><span style="color: #660033; font-weight: bold;">$b</span> <span style="color: #66cc66;">=</span> <span style="color: #cc66cc;">0</span>,<span style="color: #cc66cc;">1</span>; 0..<span style="color: #660033; font-weight: bold;">$size</span><span style="color: #66cc66;">|%</span><span style="color: #333;">&#123;</span><span style="color: #660033; font-weight: bold;">$a</span>,<span style="color: #660033; font-weight: bold;">$b</span> <span style="color: #66cc66;">=</span> <span style="color: #333;">&#40;</span><span style="color: #660033; font-weight: bold;">$a</span><span style="color: #66cc66;">+</span><span style="color: #660033; font-weight: bold;">$b</span><span style="color: #333;">&#41;</span>,<span style="color: #660033; font-weight: bold;">$a</span><span style="color: #333;">&#125;</span>; <span style="color: #660033; font-weight: bold;">$a</span><br />
Duration &nbsp; &nbsp;: 00:00:<span style="color: #cc66cc;">00.0048825</span><br />
<br />
<span style="color: #333;">&#91;</span><span style="color: #cc66cc;">15</span><span style="color: #333;">&#93;</span>: <span style="color: #003366; font-weight: bold;"><span style="color: #333;">&#91;</span><span style="color: #003366; font-weight: bold;">int</span><span style="color: #333;">&#93;</span></span><span style="color: #660033; font-weight: bold;">$size</span> <span style="color: #66cc66;">=</span> <span style="color: #cc66cc;">21</span><br />
<span style="color: #333;">&#91;</span><span style="color: #cc66cc;">16</span><span style="color: #333;">&#93;</span>: fibfunction <span style="color: #660033; font-weight: bold;">$size</span><br />
<span style="color: #cc66cc;">17711</span><br />
<span style="color: #333;">&#91;</span><span style="color: #cc66cc;">17</span><span style="color: #333;">&#93;</span>: <span style="color: #660033; font-weight: bold;">$size</span> <span style="color: #66cc66;">|</span> fibfilter<br />
<span style="color: #cc66cc;">17711</span><br />
<span style="color: #333;">&#91;</span><span style="color: #cc66cc;">18</span><span style="color: #333;">&#93;</span>: <span style="color: #003366; font-weight: bold;"><span style="color: #333;">&#91;</span><span style="color: #003366; font-weight: bold;">int</span><span style="color: #333;">&#93;</span></span><span style="color: #660033; font-weight: bold;">$a</span>,<span style="color: #003366; font-weight: bold;"><span style="color: #333;">&#91;</span><span style="color: #003366; font-weight: bold;">int</span><span style="color: #333;">&#93;</span></span><span style="color: #660033; font-weight: bold;">$b</span> <span style="color: #66cc66;">=</span> <span style="color: #cc66cc;">0</span>,<span style="color: #cc66cc;">1</span>; 0..<span style="color: #660033; font-weight: bold;">$size</span><span style="color: #66cc66;">|%</span><span style="color: #333;">&#123;</span><span style="color: #660033; font-weight: bold;">$a</span>,<span style="color: #660033; font-weight: bold;">$b</span> <span style="color: #66cc66;">=</span> <span style="color: #333;">&#40;</span><span style="color: #660033; font-weight: bold;">$a</span><span style="color: #66cc66;">+</span><span style="color: #660033; font-weight: bold;">$b</span><span style="color: #333;">&#41;</span>,<span style="color: #660033; font-weight: bold;">$a</span><span style="color: #333;">&#125;</span>; <span style="color: #660033; font-weight: bold;">$a</span><br />
<span style="color: #cc66cc;">17711</span><br />
<span style="color: #333;">&#91;</span><span style="color: #cc66cc;">19</span><span style="color: #333;">&#93;</span>: <span style="color: #0066cc; font-style: italic;">get-<span style="font-style: normal;">history</span></span> <span style="color: #000066;">-count</span> <span style="color: #cc66cc;">3</span> <span style="color: #66cc66;">|</span> <span style="color: #660033;">fl</span> CommandLine,@<span style="color: #333;">&#123;</span>l<span style="color: #66cc66;">=</span><span style="color: #009900;">&quot;Duration&quot;</span>; e<span style="color: #66cc66;">=</span><span style="color: #333;">&#123;</span><span style="color: #660033; font-weight: bold;">$_</span>.<span style="color: #003366;">EndExecutionTime</span> <span style="color: #66cc66;">-</span> <span style="color: #660033; font-weight: bold;">$_</span>.<span style="color: #003366;">StartExecutionTime</span><span style="color: #333;">&#125;</span><span style="color: #333;">&#125;</span><br />
<br />
CommandLine : <span style="color: #660033; font-weight: bold;">$null</span> <span style="color: #66cc66;">=</span> fibfunction <span style="color: #660033; font-weight: bold;">$size</span><br />
Duration &nbsp; &nbsp;: 00:00:<span style="color: #cc66cc;">10.5764715</span><br />
<br />
CommandLine : <span style="color: #660033; font-weight: bold;">$null</span> <span style="color: #66cc66;">=</span> <span style="color: #660033; font-weight: bold;">$size</span> <span style="color: #66cc66;">|</span> fibfilter<br />
Duration &nbsp; &nbsp;: 00:00:<span style="color: #cc66cc;">09.6282900</span><br />
<br />
CommandLine : <span style="color: #660033; font-weight: bold;">$null</span> <span style="color: #66cc66;">=</span> <span style="color: #003366; font-weight: bold;"><span style="color: #333;">&#91;</span><span style="color: #003366; font-weight: bold;">int</span><span style="color: #333;">&#93;</span></span><span style="color: #660033; font-weight: bold;">$a</span>,<span style="color: #003366; font-weight: bold;"><span style="color: #333;">&#91;</span><span style="color: #003366; font-weight: bold;">int</span><span style="color: #333;">&#93;</span></span><span style="color: #660033; font-weight: bold;">$b</span> <span style="color: #66cc66;">=</span> <span style="color: #cc66cc;">0</span>,<span style="color: #cc66cc;">1</span>; 0..<span style="color: #660033; font-weight: bold;">$size</span><span style="color: #66cc66;">|%</span><span style="color: #333;">&#123;</span><span style="color: #660033; font-weight: bold;">$a</span>,<span style="color: #660033; font-weight: bold;">$b</span> <span style="color: #66cc66;">=</span> <span style="color: #333;">&#40;</span><span style="color: #660033; font-weight: bold;">$a</span><span style="color: #66cc66;">+</span><span style="color: #660033; font-weight: bold;">$b</span><span style="color: #333;">&#41;</span>,<span style="color: #660033; font-weight: bold;">$a</span><span style="color: #333;">&#125;</span>; <span style="color: #660033; font-weight: bold;">$a</span><br />
Duration &nbsp; &nbsp;: 00:00:<span style="color: #cc66cc;">00.0058590</span></div>

	<p>P.S.: The numbers in braces with the colon (like [18]: ... ) is my prompt.</p>]]></content:encoded>
			<wfw:commentRss>http://huddledmasses.org/recursion-in-powershell-slow/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Fibonacci Sequence &#8230; in PowerShell</title>
		<link>http://huddledmasses.org/fibbonaci-sequence-in-powershell/</link>
		<comments>http://huddledmasses.org/fibbonaci-sequence-in-powershell/#comments</comments>
		<pubDate>Thu, 31 Jan 2008 05:52:41 +0000</pubDate>
		<dc:creator>Joel 'Jaykul' Bennett</dc:creator>
				<category><![CDATA[Huddled]]></category>
		<category><![CDATA[Computation]]></category>
		<category><![CDATA[Fibonacci]]></category>
		<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[Scripting]]></category>

		<guid isPermaLink="false">http://HuddledMasses.org/fibbonaci-sequence-in-powershell/</guid>
		<description><![CDATA[Scott Hanselman has been posting weekly snippets of code in various languages &#8230; today he did Fibonacci sequences &#8230; by the way, the point of his posts is to get you to read code in other languages, not necessarily showing the best way to do things in any of the languages represented &#8212; you only [...]]]></description>
			<content:encoded><![CDATA[	<p><a href="http://www.hanselman.com/blog/TheWeeklySourceCode13FibonacciEdition.aspx">Scott Hanselman</a> has been posting weekly snippets of code in various languages &#8230;  today he did Fibonacci sequences &#8230;  by the way, the point of his posts is to get you to read code in other languages, not necessarily showing the <strong>best</strong> way to do things in any of the languages represented &#8212; you only solve fibonacci sequences recursively in demos, not in real life.  Well, except perhaps in tightly optimized tail-recursion languages, maybe in Haskell &#8230;</p>

	<h4>In C#</h4>

	<div class="csharp code csharp" style="font-family:monospace;"><br />
<span style="color: #FF0000;">int</span> fib<span style="color: #000000;">&#40;</span><span style="color: #FF0000;">int</span> x<span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span> <span style="color: #0600FF;">return</span> <span style="color: #000000;">&#40;</span>x<span style="color: #008000;">&lt;</span><span style="color: #FF0000;">2</span><span style="color: #000000;">&#41;</span> <span style="color: #008000;">?</span> <span style="color: #FF0000;">1</span> <span style="color: #008000;">:</span>fib<span style="color: #000000;">&#40;</span>x<span style="color: #008000;">-</span><span style="color: #FF0000;">1</span><span style="color: #000000;">&#41;</span> <span style="color: #008000;">+</span> fib<span style="color: #000000;">&#40;</span>x<span style="color: #008000;">-</span><span style="color: #FF0000;">2</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#125;</span><br />
fib<span style="color: #000000;">&#40;</span><span style="color: #FF0000;">20</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span></div>

	<h4>In PowerShell</h4>

	<div class="posh code posh" style="font-family:monospace;"><br />
<span style="color: #666699; font-weight: bold;">filter</span> fib<span style="color: #333;">&#123;</span> <span style="color: #666699; font-weight: bold;">if</span><span style="color: #333;">&#40;</span><span style="color: #660033; font-weight: bold;">$_</span><span style="color: #66cc66;">-</span>lt2<span style="color: #333;">&#41;</span><span style="color: #333;">&#123;</span><span style="color: #cc66cc;">1</span><span style="color: #333;">&#125;</span><span style="color: #666699; font-weight: bold;">else</span><span style="color: #333;">&#123;</span><span style="color: #333;">&#40;</span><span style="color: #660033; font-weight: bold;">$_</span><span style="color: #66cc66;">-</span><span style="color: #cc66cc;">1</span><span style="color: #66cc66;">|</span>fib<span style="color: #333;">&#41;</span><span style="color: #66cc66;">+</span><span style="color: #333;">&#40;</span><span style="color: #660033; font-weight: bold;">$_</span><span style="color: #66cc66;">-</span><span style="color: #cc66cc;">2</span><span style="color: #66cc66;">|</span>fib<span style="color: #333;">&#41;</span><span style="color: #333;">&#125;</span><span style="color: #333;">&#125;</span><br />
<span style="color: #cc66cc;">20</span> <span style="color: #66cc66;">|</span> fib</div>

	<p>That&#8217;s just beautiful  <img src='http://huddledmasses.org/wordpress/wp-includes/' alt=';)' class='wp-smiley' />   ... incidentally, by default, PowerShell will only recurse up to 100 levels in the stack, so it kind-of sucks at recursive calls.  You could also write that as a traditional function in powershell, but the way powershell passes arguments to functions makes it really awkward.  I&#8217;ll put it on multiple lines so you can read it easier.</p>

	<div class="posh code posh" style="font-family:monospace;"><br />
<span style="color: #666699; font-weight: bold;">function</span> fib<span style="color: #333;">&#40;</span><span style="color: #660033; font-weight: bold;">$i</span><span style="color: #333;">&#41;</span><span style="color: #333;">&#123;</span> <br />
&nbsp; <span style="color: #666699; font-weight: bold;">if</span><span style="color: #333;">&#40;</span><span style="color: #660033; font-weight: bold;">$i</span> <span style="color: #000066;">-lt</span> <span style="color: #cc66cc;">2</span><span style="color: #333;">&#41;</span> <span style="color: #333;">&#123;</span> <br />
&nbsp; &nbsp; <span style="color: #cc66cc;">1</span> <br />
&nbsp; <span style="color: #333;">&#125;</span><span style="color: #666699; font-weight: bold;">else</span><span style="color: #333;">&#123;</span> <br />
&nbsp; &nbsp; <span style="color: #666666; font-style: italic;"># yes, every one of these parentheses is required</span><br />
&nbsp; &nbsp; <span style="color: #333;">&#40;</span>fib <span style="color: #333;">&#40;</span><span style="color: #660033; font-weight: bold;">$i</span><span style="color: #66cc66;">-</span><span style="color: #cc66cc;">1</span><span style="color: #333;">&#41;</span><span style="color: #333;">&#41;</span> <span style="color: #66cc66;">+</span> <span style="color: #333;">&#40;</span>fib <span style="color: #333;">&#40;</span><span style="color: #660033; font-weight: bold;">$i</span><span style="color: #66cc66;">-</span><span style="color: #cc66cc;">2</span><span style="color: #333;">&#41;</span><span style="color: #333;">&#41;</span> <br />
&nbsp; <span style="color: #333;">&#125;</span><br />
<span style="color: #333;">&#125;</span><br />
<br />
fib <span style="color: #cc66cc;">20</span></div>

	<p>As a side note, that function actually <a href="http://blogs.msdn.com/powershell/archive/2008/01/28/lightweight-performance-testing-with-powershell.aspx">runs measurably slower</a> than the pipeline method &#8230; but speeds up noticeably if you stick a few <code>[int]</code> type specifiers in the right places so PowerShell doesn&#8217;t have to infer types &#8212; something to think about.</p>]]></content:encoded>
			<wfw:commentRss>http://huddledmasses.org/fibbonaci-sequence-in-powershell/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>

