Java
class Main {
public static void main(String[] args) {
int value = 20;
int[] list = new int[value];
list[0] = 0;
list[1] = 1;
for (int i = 2; i < value; i++) {
list[i] = list[i - 1] + list[i - 2];
}
for (int i = 0; i < value; i++) {
System.out.print(list[i] + " ");
}
}
}
Javascript
const fiboSeries = value => {
let list = [0, 1]
for(let i = 2; i <= value - 1; i++){
list[i] = list[i - 1] + list[i - 2]
}
return list
}
const answer = fiboSeries(20)
console.log(answer)
Top comments (0)