0
How to print a fibonacci series as output using user input
2 Respuestas
+ 1
x = input ("Fibonacci series")
print (x)
LOL
(I'm idiot)
0
1- You enter a number.
2- if your number is less or equal to 2, the result would be 1.
3- if your number is strictly greater than 2, say X.
You return (X-2) + (X-1) and keep calling the same function.
Here is my code using a function call
def fibonacci(n):
if n <= 2:
return 1
else:
return (fibonacci(n-1) + fibonacci(n-2))
x = input("ENTER YOUR NUMBER: ")
print(fibonacci(x))