0

How to write a program on fabocci series

25th Feb 2022, 12:47 AM
Shreshta N
13 Answers
0
Yeah.. But I want to know code
25th Feb 2022, 1:58 AM
Shreshta N
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?
25th Feb 2022, 2:00 AM
William Owens
William Owens - avatar
0
Like... Taking a=0 B=1...
25th Feb 2022, 2:02 AM
Shreshta N
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?
25th Feb 2022, 2:04 AM
William Owens
William Owens - avatar
0
Ok👍🏻
25th Feb 2022, 2:06 AM
Shreshta N
0
William Owens thank you
25th Feb 2022, 2:06 AM
Shreshta N
0
Welcome. How many don't follow Fn = Fn-1 + Fn-2, where n > 1? 0,. 1,. 1,. 2,. 3,. etc
25th Feb 2022, 2:08 AM
William Owens
William Owens - avatar
0
I have taken n=15... So yeah.. 377?
25th Feb 2022, 2:28 AM
Shreshta N
0
Study this and see how it works. I have to get some shuteye.
25th Feb 2022, 3:00 AM
William Owens
William Owens - avatar
0
Yeah sure 👍🏻 Yes..ig time is 10:05
25th Feb 2022, 3:04 AM
Shreshta N
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/
25th Feb 2022, 10:34 AM
Vineet Dhaimodker
Vineet Dhaimodker - avatar
- 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.
25th Feb 2022, 1:56 AM
William Owens
William Owens - avatar
- 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
25th Feb 2022, 2:59 AM
William Owens
William Owens - avatar