Python Quiz 5 --- "Fibonacci Series"
Python Quiz 5 ---
"Fibonacci Series"
The PROGRAM or TUTORIAL is about a "Fibonacci Series"
Fibonacci Series - The Fibonacci sequence is a set of numbers that starts with a one or a zero, followed by a one, and proceeds based on the rule that each number (called a Fibonacci number) is equal to the sum of the preceding two numbers. ... F (0) = 0, 1, 1, 2, 3, 5, 8, 13, 21, 34 ...
SOLUTION:
# Fibonacci Series
# 0 1 1 2 3 5 8 13
def fibonacci(n):
if n == 1:
return 0
elif n == 2:
return 1
else:
return fibonacci(n - 1) + fibonacci(n - 2)
number1 = int(input("Enter then number\n"))
print(fibonacci(number1))
Comments
Post a Comment