Skip to content

Instantly share code, notes, and snippets.

@hute37
Forked from aananya27/simple_fab
Created January 31, 2020 08:27
Show Gist options
  • Save hute37/c5a6a06354be35487bbf68f5022b9523 to your computer and use it in GitHub Desktop.
Save hute37/c5a6a06354be35487bbf68f5022b9523 to your computer and use it in GitHub Desktop.
import time
def fibonacci_sequence_of(num):
first_number = 0
second_number = 1
num = int(num)
if num == 0:
print ("Fibonacci of {} is {}".format(num,num))
elif num ==1:
print ("Fibonacci of {} is {}".format(num,num))
else:
for i in range(2,num):
new_number = first_number + second_number
first_number = second_number
second_number = new_number
print ("Fibonacci of {} is {}".format(num,num))
if __name__ == '__main__':
input_number = input("Provide comma-seperated-values for multiple values \nFabonacci of : ")
input_values=[]
input_values = input_number.split(",")
toc = time.time()
for i in input_values:
fibonacci_sequence_of(i)
tic = time.time()
time_taken=round((tic-toc)*1000, 1)
print ("It takes {} milli-seconds to calculate the fibonacci of {} concurrently".format(time_taken,input_number))
@hute37
Copy link
Author

hute37 commented Jan 31, 2020

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment