<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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/"
	
	>
<channel>
	<title>
	Comments on: Fibonacci in One Line Python	</title>
	<atom:link href="https://blog.finxter.com/fibonacci-in-one-line-python/feed/" rel="self" type="application/rss+xml" />
	<link>https://blog.finxter.com/fibonacci-in-one-line-python/</link>
	<description></description>
	<lastBuildDate>Sat, 15 Aug 2020 10:07:49 +0000</lastBuildDate>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=7.0.1</generator>
	<item>
		<title>
		By: Christian		</title>
		<link>https://blog.finxter.com/fibonacci-in-one-line-python/#comment-623</link>

		<dc:creator><![CDATA[Christian]]></dc:creator>
		<pubDate>Tue, 25 Jun 2019 20:29:02 +0000</pubDate>
		<guid isPermaLink="false">https://blog.finxter.com/?p=3655#comment-623</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://blog.finxter.com/fibonacci-in-one-line-python/#comment-620&quot;&gt;Thomas&lt;/a&gt;.

If you consider 0 as the first Fibonacci number, 34 is the tenth Fibonacci number (e.g. https://www.mathsisfun.com/numbers/fibonacci-sequence.html). I would not consider the number 0 as the &quot;zeroth&quot; Fibonacci number (but the first one). Thus, fib(10) should be considered the &quot;eleventh&quot; Fibonacci number -- much like the indexing l[10] returns the eleventh list element.

Anyways, I&#039;ve adapted the problem formulation to avoid further confusions: ... (starting from the first Fibonacci number 0)]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://blog.finxter.com/fibonacci-in-one-line-python/#comment-620">Thomas</a>.</p>
<p>If you consider 0 as the first Fibonacci number, 34 is the tenth Fibonacci number (e.g. <a href="https://www.mathsisfun.com/numbers/fibonacci-sequence.html" rel="nofollow ugc">https://www.mathsisfun.com/numbers/fibonacci-sequence.html</a>). I would not consider the number 0 as the &#8220;zeroth&#8221; Fibonacci number (but the first one). Thus, fib(10) should be considered the &#8220;eleventh&#8221; Fibonacci number &#8212; much like the indexing l[10] returns the eleventh list element.</p>
<p>Anyways, I&#8217;ve adapted the problem formulation to avoid further confusions: &#8230; (starting from the first Fibonacci number 0)</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Thomas		</title>
		<link>https://blog.finxter.com/fibonacci-in-one-line-python/#comment-620</link>

		<dc:creator><![CDATA[Thomas]]></dc:creator>
		<pubDate>Mon, 24 Jun 2019 16:28:36 +0000</pubDate>
		<guid isPermaLink="false">https://blog.finxter.com/?p=3655#comment-620</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://blog.finxter.com/fibonacci-in-one-line-python/#comment-617&quot;&gt;Christian&lt;/a&gt;.

Definitely it doesn´t depend. Even if you include fib(0) = 0 still fib(10) is 55 and not 34. The first 21 Fibonacci numbers F(n) for n = 0, 1, 2, ..., 20 are:

F0	F1	F2	F3	F4	F5	F6	F7	F8	F9	F10	F11	F12	F13	F14	
0	1	1	2	3	5	8	13	21	34	55	89	144	233	377
F15	F16	F17	 F18	  F19	F20
610	987	1597 2584 4181	6765]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://blog.finxter.com/fibonacci-in-one-line-python/#comment-617">Christian</a>.</p>
<p>Definitely it doesn´t depend. Even if you include fib(0) = 0 still fib(10) is 55 and not 34. The first 21 Fibonacci numbers F(n) for n = 0, 1, 2, &#8230;, 20 are:</p>
<p>F0	F1	F2	F3	F4	F5	F6	F7	F8	F9	F10	F11	F12	F13	F14<br />
0	1	1	2	3	5	8	13	21	34	55	89	144	233	377<br />
F15	F16	F17	 F18	  F19	F20<br />
610	987	1597 2584 4181	6765</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Christian		</title>
		<link>https://blog.finxter.com/fibonacci-in-one-line-python/#comment-617</link>

		<dc:creator><![CDATA[Christian]]></dc:creator>
		<pubDate>Mon, 24 Jun 2019 09:02:00 +0000</pubDate>
		<guid isPermaLink="false">https://blog.finxter.com/?p=3655#comment-617</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://blog.finxter.com/fibonacci-in-one-line-python/#comment-609&quot;&gt;Thomas&lt;/a&gt;.

Hey Thomas! :)
I guess it depends -- sometimes 0 is included into the Fibonacci sequence, sometimes not. Even the Wikipedia article you cite indicates that the sequence may start with 0... Anyway, great comment - thanks! :)]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://blog.finxter.com/fibonacci-in-one-line-python/#comment-609">Thomas</a>.</p>
<p>Hey Thomas! 🙂<br />
I guess it depends &#8212; sometimes 0 is included into the Fibonacci sequence, sometimes not. Even the Wikipedia article you cite indicates that the sequence may start with 0&#8230; Anyway, great comment &#8211; thanks! 🙂</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Christian		</title>
		<link>https://blog.finxter.com/fibonacci-in-one-line-python/#comment-616</link>

		<dc:creator><![CDATA[Christian]]></dc:creator>
		<pubDate>Mon, 24 Jun 2019 08:48:51 +0000</pubDate>
		<guid isPermaLink="false">https://blog.finxter.com/?p=3655#comment-616</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://blog.finxter.com/fibonacci-in-one-line-python/#comment-606&quot;&gt;Kouadio Aime KOUAKOU&lt;/a&gt;.

Like it -- very concise! :)]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://blog.finxter.com/fibonacci-in-one-line-python/#comment-606">Kouadio Aime KOUAKOU</a>.</p>
<p>Like it &#8212; very concise! 🙂</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Thomas		</title>
		<link>https://blog.finxter.com/fibonacci-in-one-line-python/#comment-609</link>

		<dc:creator><![CDATA[Thomas]]></dc:creator>
		<pubDate>Sat, 22 Jun 2019 13:54:06 +0000</pubDate>
		<guid isPermaLink="false">https://blog.finxter.com/?p=3655#comment-609</guid>

					<description><![CDATA[Hi Chris,
nice article but the result is faulty.
fib(10) is 55 and not 34 which is the last number in your printed fibs list.
https://en.wikipedia.org/wiki/Fibonacci_number
Better code:
# The One-Liner
fibs = reduce(lambda x, _: x + [x[-2] + x[-1]], [0] * (n-2), [1, 1])
# The Result
print(fibs[-1])]]></description>
			<content:encoded><![CDATA[<p>Hi Chris,<br />
nice article but the result is faulty.<br />
fib(10) is 55 and not 34 which is the last number in your printed fibs list.<br />
<a href="https://en.wikipedia.org/wiki/Fibonacci_number" rel="nofollow ugc">https://en.wikipedia.org/wiki/Fibonacci_number</a><br />
Better code:<br />
# The One-Liner<br />
fibs = reduce(lambda x, _: x + [x[-2] + x[-1]], [0] * (n-2), [1, 1])<br />
# The Result<br />
print(fibs[-1])</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Kouadio Aime KOUAKOU		</title>
		<link>https://blog.finxter.com/fibonacci-in-one-line-python/#comment-606</link>

		<dc:creator><![CDATA[Kouadio Aime KOUAKOU]]></dc:creator>
		<pubDate>Fri, 21 Jun 2019 20:47:18 +0000</pubDate>
		<guid isPermaLink="false">https://blog.finxter.com/?p=3655#comment-606</guid>

					<description><![CDATA[fib=lambda n:reduce(lambda x,y:(x[0]+x[1],x[0]),[(1,1)]*(n-2))[0]]]></description>
			<content:encoded><![CDATA[<p>fib=lambda n:reduce(lambda x,y:(x[0]+x[1],x[0]),[(1,1)]*(n-2))[0]</p>
]]></content:encoded>
		
			</item>
	</channel>
</rss>

<!--
Performance optimized by W3 Total Cache. Learn more: https://www.boldgrid.com/w3-total-cache/?utm_source=w3tc&utm_medium=footer_comment&utm_campaign=free_plugin

Page Caching using Disk: Enhanced 
Minified using Disk

Served from: blog.finxter.com @ 2026-07-12 03:13:31 by W3 Total Cache
-->