Last active
January 31, 2020 08:27
-
-
Save aananya27/09ae92a99ff72a2a2d191533401e1af6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment