Python Forum
Assistance with Fibonacci code
Thread Rating:
  • 2 Vote(s) - 3 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Assistance with Fibonacci code
#1
hello There,

There is an "logic" error on my code, and I have not figured it out, what it is!!

Code:

#Fibonacci numbers

x = 1
y = 1
z = 0

while z < 1000:
x = y
y = z
z = x + y
print(z)
Why is it printing above 1000? What am I missing here? (Note, I am still very new to Python)

any help appreciated

Cheers
Colombian1976
Reply


Messages In This Thread
Assistance with Fibonacci code - by Colombian1976 - Aug-09-2017, 12:21 PM
RE: Assistance with Fibonacci code - by ichabod801 - Aug-09-2017, 01:07 PM
RE: Assistance with Fibonacci code - by Karthikeyan - Feb-16-2024, 04:59 PM
RE: Assistance with Fibonacci code - by Pedroski55 - Feb-17-2024, 12:09 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Fibonacci sequence problem is confusing me adam10e10 2 3,582 Apr-04-2019, 10:55 AM
Last Post: perfringo
  Help needed on Fibonacci series nvakada 1 2,518 Apr-25-2018, 07:12 PM
Last Post: micseydel
  Linear Fibonacci sequence Tawnwen 1 3,339 Feb-27-2018, 08:01 AM
Last Post: nilamo
  Help with fibonacci sequence masonmoore93 2 8,062 Oct-01-2017, 12:56 AM
Last Post: masonmoore93
  Fibonacci sequence logic 3 4,822 Jun-11-2017, 08:23 PM
Last Post: Ofnuts

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020