+ 1

find the first 20 numbers of the Fibonacci sequence and puts into a list using recursive way.. Example - List<Integer> l1 = ne

// I'm stuck and I could really use the help. import java.util.*; public class answer { public static int fib(int[] f, int n) { int ret = 0; if(n <= 2) ret = 1; else ret = fib(f, n-1) + fib(f, n-2); f[n-1] = ret; return ret; } public static void main(String[] args) { // TODO Auto-generated method stub List<Integer> ll = new ArrayList<Integer>(20); ll.add(0, 1); ll.add(1, 2); int[] f = new int[20]; fib(f, 20); for(int i = 0; i < 20; i++) System.out.print(ll); } }

5th Sep 2019, 10:29 PM
Ify Nonyelu
10 Respostas
5th Sep 2019, 11:01 PM
Eliya Ben Baruch
Eliya Ben Baruch - avatar
+ 1
Please do not write sentence in Relevant Tags 👍
5th Sep 2019, 11:03 PM
Ipang
5th Sep 2019, 11:17 PM
Eliya Ben Baruch
Eliya Ben Baruch - avatar
+ 1
Ify Nonyelu look at the code I sent
5th Sep 2019, 11:17 PM
Eliya Ben Baruch
Eliya Ben Baruch - avatar
+ 1
Ok Ellya and Maria and thank you both
5th Sep 2019, 11:20 PM
Ify Nonyelu
0
I have to use a list but I'm not sure how to do it.
5th Sep 2019, 11:16 PM
Ify Nonyelu