<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://sqlblog.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Simple Fibonacci calculation</title><link>http://sqlblog.com/blogs/peter_larsson/archive/2009/10/18/simple-fibonacci-calculation.aspx</link><description>I have listened to the critique in the comments and removed the advanced version where you can calculate virtually any Fibonacci number. Contact me if you have the need for it again. I won't bother non-interested people with the algorithm here. Instead,</description><dc:language>en</dc:language><generator>CommunityServer 2.1 SP2 (Build: 61129.1)</generator><item><title>re: Simple Fibonacci calculation</title><link>http://sqlblog.com/blogs/peter_larsson/archive/2009/10/18/simple-fibonacci-calculation.aspx#17884</link><pubDate>Sun, 18 Oct 2009 14:16:30 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:17884</guid><dc:creator>Paul Nielsen</dc:creator><description>&lt;p&gt;very cool. well done. &lt;/p&gt;
&lt;p&gt;-Pn&lt;/p&gt;</description></item><item><title>re: Simple Fibonacci calculation</title><link>http://sqlblog.com/blogs/peter_larsson/archive/2009/10/18/simple-fibonacci-calculation.aspx#17954</link><pubDate>Mon, 19 Oct 2009 17:53:16 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:17954</guid><dc:creator>John Meriweather</dc:creator><description>&lt;p&gt;What's the point of calculating the Fibonacci series in T-SQL? And why would anyone use t-SQL for that calculation?&lt;/p&gt;</description></item><item><title>re: Simple Fibonacci calculation</title><link>http://sqlblog.com/blogs/peter_larsson/archive/2009/10/18/simple-fibonacci-calculation.aspx#18003</link><pubDate>Tue, 20 Oct 2009 15:00:44 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:18003</guid><dc:creator>Jason</dc:creator><description>&lt;p&gt;@Peter: This is a great example of a bad post. &amp;nbsp;&lt;/p&gt;
&lt;p&gt;First of all, you only provide a heap of code with no explanation as to why it is interesting (thanks Peso) or how you might use it.&lt;/p&gt;
&lt;p&gt;Second, your code essentially implements the addition operator for strings instead of just using the built in &amp;quot;+&amp;quot;, which is just stupid. &amp;nbsp;&lt;/p&gt;
&lt;p&gt;@Paul: This post is neither cool nor well done.&lt;/p&gt;</description></item><item><title>re: Simple Fibonacci calculation</title><link>http://sqlblog.com/blogs/peter_larsson/archive/2009/10/18/simple-fibonacci-calculation.aspx#18012</link><pubDate>Tue, 20 Oct 2009 17:25:16 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:18012</guid><dc:creator>Linchi Shea</dc:creator><description>&lt;p&gt;I don't think John was questioning the significance of the Fibonacci series, but rather why one would do it with T-SQL. For classroom exercises and seminar demos, it's fine. It's also fine if one just wants to kill some time. But I'd agree that people should probably be cautioned not to actually end up writing production T-SQL code to do Fibonacci searies. Well, maybe there is a real case where writing it in T-SQL is justified. But it is certianly difficult to come up with one.&lt;/p&gt;</description></item><item><title>re: Simple Fibonacci calculation</title><link>http://sqlblog.com/blogs/peter_larsson/archive/2009/10/18/simple-fibonacci-calculation.aspx#18022</link><pubDate>Tue, 20 Oct 2009 18:54:00 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:18022</guid><dc:creator>Peso</dc:creator><description>&lt;p&gt;New content posted.&lt;/p&gt;</description></item><item><title>re: Simple Fibonacci calculation</title><link>http://sqlblog.com/blogs/peter_larsson/archive/2009/10/18/simple-fibonacci-calculation.aspx#18068</link><pubDate>Wed, 21 Oct 2009 13:51:18 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:18068</guid><dc:creator>Jason</dc:creator><description>&lt;p&gt;Hi Peter,&lt;/p&gt;
&lt;p&gt;I like the revisions you made to this article. &amp;nbsp;Much more interesting. &amp;nbsp;&lt;/p&gt;
&lt;p&gt;As an alternative to BIGINT, you could use DECIMAL(38,0) and calculate up to the 184th number in the sequence.&lt;/p&gt;
&lt;p&gt;Thanks, Jason&lt;/p&gt;</description></item><item><title>re: Simple Fibonacci calculation</title><link>http://sqlblog.com/blogs/peter_larsson/archive/2009/10/18/simple-fibonacci-calculation.aspx#18221</link><pubDate>Sun, 25 Oct 2009 13:49:50 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:18221</guid><dc:creator>Joe Celko</dc:creator><description>&lt;p&gt;Wouldn't it be faster to use the constant phi and the closed form?&lt;/p&gt;
&lt;p&gt;Fibonacci(@n INTEGER)&lt;/p&gt;
&lt;p&gt;AS &lt;/p&gt;
&lt;p&gt;RETURN&lt;/p&gt;
&lt;p&gt; EOUND (((POWER (1.6190339887, @n)- POWER (1.0 - 1.6190339887, @n))/ &lt;/p&gt;
&lt;p&gt;SQRT (5.0)), 0);&lt;/p&gt;
&lt;p&gt;untested.&lt;/p&gt;</description></item><item><title>re: Simple Fibonacci calculation</title><link>http://sqlblog.com/blogs/peter_larsson/archive/2009/10/18/simple-fibonacci-calculation.aspx#18228</link><pubDate>Sun, 25 Oct 2009 16:28:46 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:18228</guid><dc:creator>Peso</dc:creator><description>&lt;p&gt;It would be great if it worked! However, the golden ration is the ration for which division of Fibonacci number converges to, when sufficiently large.&lt;/p&gt;
&lt;p&gt;However, the formula you displayed above gives wrong answer very early, and after step 12, the error is larger and larger&lt;/p&gt;
&lt;p&gt;n	Peso	Celko&lt;/p&gt;
&lt;p&gt;--	----	-----&lt;/p&gt;
&lt;p&gt;1	0	0&lt;/p&gt;
&lt;p&gt;2	1	1&lt;/p&gt;
&lt;p&gt;3	1	1&lt;/p&gt;
&lt;p&gt;4	2	2&lt;/p&gt;
&lt;p&gt;5	3	3&lt;/p&gt;
&lt;p&gt;6	5	5&lt;/p&gt;
&lt;p&gt;7	8	8&lt;/p&gt;
&lt;p&gt;8	13	13&lt;/p&gt;
&lt;p&gt;9	21	21&lt;/p&gt;
&lt;p&gt;10	34	34&lt;/p&gt;
&lt;p&gt;11	55	55&lt;/p&gt;
&lt;p&gt;12	89	90&lt;/p&gt;
&lt;p&gt;13	144	145&lt;/p&gt;</description></item><item><title>re: Simple Fibonacci calculation</title><link>http://sqlblog.com/blogs/peter_larsson/archive/2009/10/18/simple-fibonacci-calculation.aspx#18240</link><pubDate>Mon, 26 Oct 2009 06:27:40 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:18240</guid><dc:creator>RBArryYoung</dc:creator><description>&lt;p&gt;This one is accurate up to n=62:&lt;/p&gt;
&lt;p&gt; FLOOR(POWER(1.61803398874989, n)/SQRT(5) +.5)&lt;/p&gt;
&lt;p&gt;:-)&lt;/p&gt;</description></item><item><title>re: Simple Fibonacci calculation</title><link>http://sqlblog.com/blogs/peter_larsson/archive/2009/10/18/simple-fibonacci-calculation.aspx#18241</link><pubDate>Mon, 26 Oct 2009 06:52:24 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:18241</guid><dc:creator>Peso</dc:creator><description>&lt;p&gt;Much better. &lt;/p&gt;</description></item></channel></rss>