Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Fibonnaci
#12
Ooh I understand!!

It is working for a part. If I want the 2nd fibonacci number bigger than 4 it is giving 8. But if I give the 2nd bigger than 5 it gives also 8.

position_in_fib_sequence = int(input("Which fibonaccinumber do you want to know?"))
the_number_has_to_be_bigger_than = int(input("Bigger than?"))
  
G1 = 0
G2 = 1
 
while G2 < the_number_has_to_be_bigger_than:
    G1, G2 = G2, G1 + G2
  
for i in range(position_in_fib_sequence-1):
    G1, G2 = G2, G1 + G2
	
print("The", str(position_in_fib_sequence) + "th", "fibonaccinumber bigger than", the_number_has_to_be_bigger_than, "is", G2)
Reply


Messages In This Thread
Fibonnaci - by PythonNoob99 - Feb-21-2019, 09:07 PM
RE: Fibonnaci - by nilamo - Feb-21-2019, 10:17 PM
RE: Fibonnaci - by PythonNoob99 - Feb-22-2019, 03:19 PM
RE: Fibonnaci - by ichabod801 - Feb-22-2019, 03:28 PM
RE: Fibonnaci - by PythonNoob99 - Feb-22-2019, 03:32 PM
RE: Fibonnaci - by PythonNoob99 - Feb-26-2019, 11:43 AM
RE: Fibonnaci - by ichabod801 - Feb-26-2019, 04:39 PM
RE: Fibonnaci - by PythonNoob99 - Feb-26-2019, 07:39 PM
RE: Fibonnaci - by ichabod801 - Feb-27-2019, 04:32 AM
RE: Fibonnaci - by PythonNoob99 - Feb-27-2019, 05:28 PM
RE: Fibonnaci - by ichabod801 - Feb-27-2019, 06:15 PM
RE: Fibonnaci - by PythonNoob99 - Feb-28-2019, 08:35 AM
RE: Fibonnaci - by ichabod801 - Feb-28-2019, 07:32 PM
RE: Fibonnaci - by PythonNoob99 - Feb-28-2019, 07:46 PM

Forum Jump:

User Panel Messages

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