+ 1

Guys Can you please help me to solve the problem

Question is Write a program in Java to print the Fibonacci Series starting from zero. E.g.-Fibonacci Series 0,1,1,2,3,5,8.

24th May 2020, 3:58 PM
Student 31
Student 31 - avatar
10 Answers
0
Please specify what the problem is. Oh, and please provide your code, beforehand.
24th May 2020, 4:05 PM
Kuba SiekierzyƄski
Kuba SiekierzyƄski - avatar
0
I am unable to write the code Please help me out guys.
24th May 2020, 4:07 PM
Student 31
Student 31 - avatar
0
You could start from an array of [0, 1] and iteratively append new elements with value being the sum of two preceding elements. Then you will populate the array with consecutive numbers of the Fibonacci sequence.
24th May 2020, 4:16 PM
Kuba SiekierzyƄski
Kuba SiekierzyƄski - avatar
0
In the program usage of array is prohibited
24th May 2020, 4:17 PM
Student 31
Student 31 - avatar
0
Then please help me out without using any array.Just normal code.
24th May 2020, 4:18 PM
Student 31
Student 31 - avatar
0
I guess you could then start with a and b equal to 0 and 1, respectively. Then in each iteration you increase a with a+b and then b also with a+b. Then a and b will assume consecutive Fibonacci sequence elements.
24th May 2020, 4:25 PM
Kuba SiekierzyƄski
Kuba SiekierzyƄski - avatar
0
But how will I print 0 at the beginning
24th May 2020, 4:36 PM
Student 31
Student 31 - avatar
0
You can start the loop with the printing statement and then start incrementing
24th May 2020, 4:43 PM
Kuba SiekierzyƄski
Kuba SiekierzyƄski - avatar
0
Do it through with the recursion
26th May 2020, 1:29 PM
pradeep $ingh
pradeep $ingh - avatar