Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
学ぶ Challenge: Printing Fibonacci Sequence | Section
JavaScript Fundamentals
セクション 1.  68
single

single

bookChallenge: Printing Fibonacci Sequence

メニューを表示するにはスワイプしてください

タスク

スワイプしてコーディングを開始

The Fibonacci sequence is a series of numbers where each term is the sum of the previous two. The sequence starts with:

0, 1, 1, 2, 3, 5, 8, 13, ...

Your task is to generate the first n Fibonacci numbers.

Instructions:

  1. Initialize:
    let a = 0;
    let b = 1;
    let numTerms = 10;
    
  2. Use a while loop to generate the sequence.
  3. In every iteration:
    • Add the current value of a to an array.
    • Create a variable nextTerm = a + b.
    • Update a = b.
    • Update b = nextTerm.
    • Decrement numTerms.
  4. Return the full Fibonacci sequence as an array.

解答

Switch to desktop実践的な練習のためにデスクトップに切り替える下記のオプションのいずれかを利用して、現在の場所から続行する
すべて明確でしたか?

どのように改善できますか?

フィードバックありがとうございます!

セクション 1.  68
single

single

AIに質問する

expand

AIに質問する

ChatGPT

何でも質問するか、提案された質問の1つを試してチャットを始めてください

some-alt