+ 2

How can I print the fibonacci series of 10 numbers in the reverse order?

the output would be like :- 55 34 21 13 8 5 3 2 1 1

5th Aug 2018, 9:27 PM
simran
simran - avatar
12 Respostas
+ 7
The easiest way is to calculate and store them in an array and print the array contents in reverse order.
5th Aug 2018, 10:12 PM
John Wells
John Wells - avatar
+ 7
Another option call the function 10 times with n of 10 to 1.
5th Aug 2018, 10:21 PM
John Wells
John Wells - avatar
+ 6
for (int n = 10; n > 0; n--) System.out.println(fibonacci(n));
5th Aug 2018, 10:24 PM
John Wells
John Wells - avatar
+ 5
Given you have the last two values, you can calculate all the others. 55 - 34 gives 21, 34 - 21 gives 13, ectereta.
5th Aug 2018, 10:15 PM
John Wells
John Wells - avatar
+ 3
oh.. okk.. thank you.. for your help.😁
5th Aug 2018, 10:25 PM
simran
simran - avatar
+ 2
what if we don't have the values then?
5th Aug 2018, 10:16 PM
simran
simran - avatar
+ 2
mm.. i didn't get.. actually its new for me!
5th Aug 2018, 10:22 PM
simran
simran - avatar
+ 2
thank you so much..😇 @Forge
5th Aug 2018, 10:42 PM
simran
simran - avatar
+ 1
thank you.. but i'm in search of this program without using an array!
5th Aug 2018, 10:14 PM
simran
simran - avatar
+ 1
Not sure my section on building the sequence is the best way to do it, but it worked for me.. Either way, the rest stands. as John said, put it into an ArrayList and then you can manipulate it as you need
5th Aug 2018, 10:44 PM
LordHill
LordHill - avatar
+ 1
i've got the output.. thank you guys for your help!😊
6th Aug 2018, 9:40 AM
simran
simran - avatar