セクション 2. 章 4
single
Challenge: Sum Threshold
メニューを表示するにはスワイプしてください
タスク
スワイプしてコーディングを開始
Write code that uses a while loop to sum all even numbers from the vector nums until the sum exceeds 50. Store the result in a variable named even_sum.
- Start with the vector:
nums <- c(8, 3, 12, 5, 10, 7, 14, 2). - Initialize the sum and a loop index variable.
- In each iteration, check if the current number is even and, if so, add it to your sum.
- Stop the loop as soon as the running sum becomes greater than 50.
- Store the final sum in a variable named
even_sum.
解答
すべて明確でしたか?
フィードバックありがとうございます!
セクション 2. 章 4
single
AIに質問する
AIに質問する
何でも質問するか、提案された質問の1つを試してチャットを始めてください