Created
February 27, 2020 12:10
-
-
Save AntonioFeijaoUK/bd55d7129eb404720aa4e5b414f1cc5c 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
def add_until(max_number): | |
result = 0 | |
first_number = 0 | |
second_number = 0 | |
while int(max_number) > int(result): | |
if first_number == 0: | |
print("First number + Second number: " + str(first_number) + " + " + str(second_number) + " = " + str(result)) | |
first_number = 1 | |
else: | |
result = first_number + second_number | |
print("First number + Second number: " + str(first_number) + " + " + str(second_number) + " = " + str(result)) | |
first_number = second_number | |
second_number = result | |
number = int(input("Run the Fibonacci sequence until reach which number? (>0) : ")) | |
add_until(number) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment