0
How to write a program on fabocci series
13 Antworten
0
Yeah..
But I want to know code
0
Let's work on it:
How can we define a variable that asks the user how many fib numbers they want?
Now we need some logic the first how many numbers don't follow Fn = Fn-1 + Fn-2, where n > 1?
0
Like...
Taking
a=0
B=1...
0
Yes but you want to ask the user so try
fibNim = int(input("How many numbers do you want?"))
Now we need some logic how many of the numbers don't follow Fn = Fn-1 + Fn-2, where n > 1?
0
Ok👍🏻
0
William Owens thank you
0
Welcome. How many don't follow Fn = Fn-1 + Fn-2, where n > 1?
0,. 1,. 1,. 2,. 3,. etc
0
I have taken n=15...
So yeah..
377?
0
Study this and see how it works. I have to get some shuteye.
0
Yeah sure 👍🏻
Yes..ig time is 10:05
0
Classic question. Geeksforgeeks has many methods to solve this
https://www.google.com/amp/s/www.geeksforgeeks.org/program-for-nth-fibonacci-number/amp/
- 1
You are trying to write a codebit to output Fn = Fn-1 + Fn-2, where n > 1, correct?
0,1,1,2,3,5,8,13,21 etc.
- 1
fib = 0
nxt = 1
fibNum = int(input("How many"))
if fibNum == 0:
print(fib)
elif fibNum == 1:
print(fib)
print(nxt)
else:
print(fib)
print(nxt)
for i in range(fibNum-2):
res = fib + nxt
print(res)
fib, nxt = nxt, res