for x =1, y is=5
for x =2, y is=8
for x =3, y is=11
The code above will print: 103
5
RonitThomas
3rd through 6th letters are:
nitT
#Use an algorithm to find certain values of the Fibonacci sequence. For example, your code should output the nth index in the sequence. An example of how the sequence works is 0,1,1,2,3,5,8,13. The pattern is you add the previous 2 numbers together to get the new number. \
# 0,1,1,2,3,5,8,13
sequence = [0, 1]
user = int(input("How numbers do you want in your sequence?"))
for i in range(0,user):
next_fib = sequence[-1] + sequence[-2]
sequence.append(next_fib)
print(sequence)
user = int(input("What index of the sequence do you want to print?"))
print("Index #" + str(user) + " is: " + str(sequence[user]))
[0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, 2584, 4181, 6765, 10946, 17711, 28657, 46368, 75025]
Index #15 is: 610