how to make program of Fibonacci series? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

how to make program of Fibonacci series?

6th Sep 2016, 5:48 PM
Sarthak Verma
Sarthak Verma - avatar
3 Answers
+ 2
public static int fibonacci_rec(int i, int curr, int prev) { if (i == 0) {return prev;} if (i == 1) {return curr;} return fibonacci_rec(i-1, curr+prev, curr); } public static int fibonacci(int i) { return fibonacci_rec(i, 1, 0); }
6th Sep 2016, 10:53 PM
Zen
Zen - avatar
17th Nov 2017, 1:44 AM
#RahulVerma
#RahulVerma - avatar
0
Python 3 - x,y,z=0,1,0 i = 400000000 while y < i: z = x + y x = y y = z print(y)
6th Sep 2016, 6:02 PM
Kevin McMinn
Kevin McMinn - avatar