
February 7th, 2012, 10:01 PM
|
 |
Contributing User
|
|
Join Date: Nov 2011
Location: Sydney, Australia
Posts: 61
Time spent in forums: 1 Day 1 h 6 m 11 sec
Reputation Power: 1
|
|
|
Fibonacci Sequence - not appending to list
Code:
fibonacci = [1, 2]
x = fibonacci[0]
y = fibonacci[1]
fourmillion = 4 ** 11 - 194304
while (fibonacci <= fourmillion):
z = x + y
fibonacci.append(z)
x = y
y = z
print fibonacci
Is there anything I should be using instead of lists here? The program runs without any errors, but only prints out [1, 2]...Is there something wrong with my syntax, which to me doesn't look to be the case, or what?
Is the while loop just not starting, or is it not appending to the list for some strange reason?
Haven't done much with while loops before, sorry if this is simple and stupid solution.
Thanks
EDIIIIIT: Maybe it is syntax error. But atm I don't know how to fix
Last edited by breadbox : February 7th, 2012 at 10:11 PM.
|