import os def fibonacci(threshold): # Assign a start value for sequence current = 1 previous = 0 # Iterate fibonacci sequence as long as value is lesser than x while current <= threshold: # Print current value print(current) # Calculate new value from current value + previous value new = current + previous # Store the current value for next iteration previous = current # Store the new value as the current value current = new # Clear screen os.system("clear") # Mac or Linux # os.system("cls") # Windows # Call function fibonacci() fibonacci(1024)