Mercurial > hg > pyloader
diff tests/objects.py @ 38:f6616a5f468f
test fibonacci sequence
author | Jeff Hammel <jhammel@mozilla.com> |
---|---|
date | Tue, 07 Jun 2011 19:17:21 -0700 |
parents | 5268ab85fe1b |
children | 49f88cde6219 |
line wrap: on
line diff
--- a/tests/objects.py Tue Jun 07 19:14:04 2011 -0700 +++ b/tests/objects.py Tue Jun 07 19:17:21 2011 -0700 @@ -39,6 +39,6 @@ def fib(n): """return the nth fibonacci term""" sequence = [1,1] - while len(sequence) < n: - sequence.append(sequence[len(sequence)-1], sequence[len(sequence)-2]) + while len(sequence) - 1 < n: + sequence.append(sequence[len(sequence)-1] + sequence[len(sequence)-2]) return sequence[n]