cartoon image
Note: Some Blogs may not be clickable. If you want to read our Blogs you can redirected to our Medium Blog Account. Hopefully You like our Blogs. Thank You for your patience.
main-image

Mastering Web Development: Secrets to Enhance Your Coding Skills

Our Latest Blogs


From The Blogs


Fibonacci Series In Python

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 .

Lets start with a question

''' Write a Python program to get the Fibonacci series between 0 to 50. Note : The Fibonacci Sequence is the series of numbers such as: 0, 1, 1, 2, 3, 5, 8, 13, 21, 34.... '''

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)

OUTPUT: 0,1,1,2,3,5,8,13,21,34,55

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 !

About

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!