セクション 1. 章 68
single
Challenge: 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:
- Initialize:
let a = 0; let b = 1; let numTerms = 10; - Use a
whileloop to generate the sequence. - In every iteration:
- Add the current value of
ato an array. - Create a variable
nextTerm = a + b. - Update
a = b. - Update
b = nextTerm. - Decrement
numTerms.
- Add the current value of
- Return the full Fibonacci sequence as an array.
解答
すべて明確でしたか?
フィードバックありがとうございます!
セクション 1. 章 68
single
AIに質問する
AIに質問する
何でも質問するか、提案された質問の1つを試してチャットを始めてください