Pergunta de entrevista da empresa CallHub

Develop a Python/Django application that will display the Nth number in Fibonacci sequence. For instance, if N is 6 and the sequence starts with [1,1..] then it should display ‘8’ as the 6th element in the sequence. Application should be hosted on the internet with an user interface asking for the input ‘N’. It should also print the time it took to get the results back to the user. What we’re looking for: A hosted solution with github link to your code (can be hosted on any cloud solution like heroku or any other) Django model, view and template design, rest APIs and implementation Tests that you write for the application code Optimisations you add to improve performance

Resposta da entrevista

Sigiloso

26 de set. de 2019

import time def fibonacci(numeric): if numeric<0: print("Incorrect Input") elif numeric<=2: return 1 elif numeric ==3: return 2 else: return fibonacci(numeric-1) + fibonacci(numeric-2) number = int(input("Enter the number which you want to check in fibonacci sequence:")) if number < 0: print("please enter the valid number") else: start_time = time.time() numeric = int(number) print("The number you have entered the :",numeric) output = fibonacci(numeric) print("{} is the {}th element the fibonaci sequence".format(output,numeric)) end_time = time.time() - start_time latency = str(end_time)[0:3] print(latency)