Python Forum
fibonacci ***Time limit exceeded***
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
fibonacci ***Time limit exceeded***
#12
Your code has an error at the last print,i will check it further as soon as i go home

optimized the code a bit for my standards
f=[1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89]
user_input = input()
while user_input !='END':
    user_input = int(user_input)
    while type(user_input)==int:
        while len(f) < user_input:
          f.append(sum(f[-2:]))
        print (f[user_input - 1])
        user_input=input()
Reply


Messages In This Thread
fibonacci ***Time limit exceeded*** - by frequency - Nov-24-2018, 02:49 AM
RE: fibonacci ***Time limit exceeded*** - by frequency - Nov-27-2018, 04:17 PM
RE: fibonacci ***Time limit exceeded*** - by nilamo - Nov-27-2018, 10:43 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Fibonacci Yasunaga 7 2,985 May-16-2021, 02:36 PM
Last Post: csr
  Assign a value if datetime is in between a particular time limit klllmmm 2 2,791 Jan-02-2021, 07:00 AM
Last Post: klllmmm
  Time Limit Exceeded error loves 5 3,188 Dec-03-2020, 07:15 AM
Last Post: Sofia_Grace
Bug maximum recursion depth exceeded while calling a Python object error in python3 Prezess 4 3,798 Aug-02-2020, 02:21 PM
Last Post: deanhystad
  RecursionError: maximum recursion depth exceeded in comparison ? leoahum 11 13,151 Mar-18-2019, 01:53 PM
Last Post: leoahum
  'Time Limit Exceeded' Problem bkpee3 2 5,481 Nov-14-2018, 03:51 AM
Last Post: bkpee3
  If conditions with time limit unknowntothem 4 3,105 Nov-09-2018, 08:59 PM
Last Post: nilamo
  Fibonacci sequence Darbandiman123 2 2,727 Sep-26-2018, 02:32 PM
Last Post: Darbandiman123
  Help debug my fibonacci implementation dineshpabbi10 6 4,034 May-16-2018, 12:12 PM
Last Post: dineshpabbi10
  maximum recursion depth exceeded saba_keon 3 7,486 Apr-08-2018, 07:30 AM
Last Post: Gribouillis

Forum Jump:

User Panel Messages

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