The series sequence in Fibonacci series, named after Italian mathematician name Leonardo Pisano Bogollo, also known as Fibonacci, is a series or sequence of sum formed by previous two terms called Fibonacci numbers and it is denoted by Fn. The numbers in sequence of Fibonacci are given by — 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, . . . In a Fibonacci series or sequence , every number is the SUM of the preceding two numbers (previous two terms), starting from 0 and 1 as first and second number .
Follow this simple steps to create a program using PYTHON:
firstly take,
x = 0
y = 1
while y< 50:
y,x = x, x+y
print(y)
Process finished with exit code 0 the correct output will come-out by using this code. Many places
the
code taken out as x, y=y, x+y and
the output will come-out from this 1, 2, 3, 5, 8, 13, 21… that means the result is missing the
starting two numbers 0 and 1 which is wrong answer (unmatched with question).
Try y, x=x, x+y
the
result will give you the correct answer. if you also have coding suggestions and queries ,let me
know in comment box thank you !
Welcome to my Portfolio Blog Section! I'm Shubhnish Verma, and here, we dive into some great topics. Explore practical insights, and join our community. Follow us on Linkedin, Medium for more updates!