DEV Community

Mahabubur Rahman
Mahabubur Rahman

Posted on

Fibonacci Series Java & Javascript

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] + " ");
        }
    }
}
Enter fullscreen mode Exit fullscreen mode

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)
Enter fullscreen mode Exit fullscreen mode

Top comments (0)

Image of Docusign

🛠️ Bring your solution into Docusign. Reach over 1.6M customers.

Docusign is now extensible. Overcome challenges with disconnected products and inaccessible data by bringing your solutions into Docusign and publishing to 1.6M customers in the App Center.

Learn more