Fibonacci's sequence
The following pattern is created if we are to visualize a never-ending sequence called Fibonacci's sequence. This sequence is created by starting with two numbers, 0 and 1. The following number is the two previous numbers added, therefor the third number in the sequence would be 1, and the fourth number in the sequence would be 2. In algebraic form: Using a recursive loop that works with only three variables, it is quite simple to create in python:
starter1 = 0
starter2 = 1
print(starter1)
print(starter2)
for x in range(0, 20):
temp = starter1 + starter2
starter1 = starter2
starter2 = temp
print(temp)
Comments
Post a Comment