Challenge: Sum Threshold
Завдання
Swipe to start coding
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
Запитати АІ
Запитати АІ
Запитайте про що завгодно або спробуйте одне із запропонованих запитань, щоб почати наш чат
Suggested prompts:
Can you explain this in simpler terms?
What are the main points I should remember?
Can you give me an example?
Чудово!
Completion показник покращився до 5.56
Challenge: Sum Threshold
Свайпніть щоб показати меню
Завдання
Swipe to start coding
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