Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Python: Bugs

[issue7369] Fibonacci example does not include 0; section 4.6

 

 

Python bugs RSS feed   Index | Next | Previous | View Threaded


report at bugs

Nov 20, 2009, 5:50 AM

Post #1 of 8 (473 views)
Permalink
[issue7369] Fibonacci example does not include 0; section 4.6

New submission from prm225 <prm225 [at] gmail>:

The example starts off with 1 being printed, while the series is
expected to begin with 0 and 1.
The example in 4.6 (defining functions) should have been:

def fib(n):
a, b = 0, 1
while a < n:
print a,
a, b = b, a+b
fib(2000)

0 1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 987 1597

----------
assignee: georg.brandl
components: Documentation
messages: 95542
nosy: georg.brandl, prm225
severity: normal
status: open
title: Fibonacci example does not include 0; section 4.6
versions: Python 2.6

_______________________________________
Python tracker <report [at] bugs>
<http://bugs.python.org/issue7369>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com


report at bugs

Nov 20, 2009, 5:55 AM

Post #2 of 8 (445 views)
Permalink
[issue7369] Fibonacci example does not include 0; section 4.6 [In reply to]

Mark Dickinson <dickinsm [at] gmail> added the comment:

That depends on whether you want to start the sequence with F_0 (=0) or
F_1 (=1), I guess. Given Python's general preferences for zero-based
indexing, I agree that this very serious issue should be fixed.

See

http://www.research.att.com/~njas/sequences/A000045

for an authoritative reference.

----------
nosy: +mark.dickinson

_______________________________________
Python tracker <report [at] bugs>
<http://bugs.python.org/issue7369>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com


report at bugs

Nov 20, 2009, 10:02 AM

Post #3 of 8 (436 views)
Permalink
[issue7369] Fibonacci example does not include 0; section 4.6 [In reply to]

Changes by Raymond Hettinger <rhettinger [at] users>:


----------
priority: -> critical

_______________________________________
Python tracker <report [at] bugs>
<http://bugs.python.org/issue7369>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com


report at bugs

Nov 20, 2009, 2:02 PM

Post #4 of 8 (427 views)
Permalink
[issue7369] Fibonacci example does not include 0; section 4.6 [In reply to]

Terry J. Reedy <tjreedy [at] udel> added the comment:

The delta (patch) is to change 'b' to 'a' in the while and print
statements and prepend '0 ' to the output line.

----------
nosy: +tjreedy

_______________________________________
Python tracker <report [at] bugs>
<http://bugs.python.org/issue7369>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com


report at bugs

Nov 22, 2009, 9:37 AM

Post #5 of 8 (389 views)
Permalink
[issue7369] Fibonacci example does not include 0; section 4.6 [In reply to]

Senthil Kumaran <orsenthil [at] gmail> added the comment:

tjreedy: The reporter's suggestion seems fine. Prepending a 0 does not
seem to be a good idea.

----------
nosy: +orsenthil

_______________________________________
Python tracker <report [at] bugs>
<http://bugs.python.org/issue7369>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com


report at bugs

Nov 22, 2009, 2:49 PM

Post #6 of 8 (387 views)
Permalink
[issue7369] Fibonacci example does not include 0; section 4.6 [In reply to]

Terry J. Reedy <tjreedy [at] udel> added the comment:

Senthil: look again. The OP's suggestion *is* to prepend a 0 to the current
1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 987 1597
I just specified the delta between current and suggested, should someone
decide to make the change.

That said, def fib2(n), a little further on in 4.6, should get the same
edit as def fib(n) does.

----------

_______________________________________
Python tracker <report [at] bugs>
<http://bugs.python.org/issue7369>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com


report at bugs

Nov 22, 2009, 4:18 PM

Post #7 of 8 (387 views)
Permalink
[issue7369] Fibonacci example does not include 0; section 4.6 [In reply to]

Senthil Kumaran <orsenthil [at] gmail> added the comment:

Terry: Oh, sorry. Now I get what you meant by "Prepend O to output
line". That is, Output line from the fib, as part of the patch. The
changes need to be done at 3 places. Section 3.2, twice in Section 4.6.

----------

_______________________________________
Python tracker <report [at] bugs>
<http://bugs.python.org/issue7369>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com


report at bugs

Nov 23, 2009, 8:43 AM

Post #8 of 8 (368 views)
Permalink
[issue7369] Fibonacci example does not include 0; section 4.6 [In reply to]

Mark Dickinson <dickinsm [at] gmail> added the comment:

Fixed in r76460 through r76463.

----------
resolution: -> fixed
status: open -> closed
versions: +Python 2.7, Python 3.1, Python 3.2

_______________________________________
Python tracker <report [at] bugs>
<http://bugs.python.org/issue7369>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com

Python bugs RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.