shamsmosowi / git-bot

0 stars 0 forks source link

How can I calculate fibonacci series in Javascript? #19

Open htuerker opened 1 year ago

shamsmosowi commented 1 year ago

Hi,

You can use JavaScript to calculate the Fibonacci series. This is a mathematical sequence that is formed by adding the two previous numbers to get the next number in the sequence.

You can use a for loop to iterate through the numbers and calculate the Fibonacci series. The code would look something like this:

let a = 0, b = 1;

for(let i = 0; i < n; i++) {
    let c = a + b;
    a = b;
    b = c;
    console.log(c);
}

This code will print out the first n numbers of the Fibonacci series.

I hope this helps!