Answers for "fibonacci series in python w3schools"

3

fibonacci series in python

~~ This is the best Fibonacci sequence generator as you have all the option that 
till what number should this go on for ~~
  
a = 0
b = 1
f = 1
n = int(input("Till what number would you like to see the fibonacci sequence: "))
while b <= n:
    f = a+b
    a = b
    b = f
    print(a)
Posted by: Guest on January-22-2021
5

fibonacci series in python w3schools

# Program to display the Fibonacci sequence up to n-th term

nterms = int(input("How many terms? "))

# first two terms
n1, n2 = 0, 1
count = 0

# check if the number of terms is valid
if nterms <= 0:
   print("Please enter a positive integer")
elif nterms == 1:
   print("Fibonacci sequence upto",nterms,":")
   print(n1)
else:
   print("Fibonacci sequence:")
   while count < nterms:
       print(n1)
       nth = n1 + n2
       # update values
       n1 = n2
       n2 = nth
       count += 1
Posted by: Guest on May-12-2020
3

0 1 1 2 3 5 in python

number1 = 0
print('1:', number1)
number2 = 1
for count in range(2, 101):
  print(count, ':', number1 + number2)
  number1 += number2
  number2 = number1 - number2
Posted by: Guest on October-24-2020

Code answers related to "fibonacci series in python w3schools"

Python Answers by Framework

Browse Popular Code Answers by Language