Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Impara Challenge: Sum Threshold | R Loops Tutorial
Control Flow in R

bookChallenge: Sum Threshold

Compito

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.

Soluzione

Tutto è chiaro?

Come possiamo migliorarlo?

Grazie per i tuoi commenti!

Sezione 2. Capitolo 4
single

single

Chieda ad AI

expand

Chieda ad AI

ChatGPT

Chieda pure quello che desidera o provi una delle domande suggerite per iniziare la nostra conversazione

close

bookChallenge: Sum Threshold

Scorri per mostrare il menu

Compito

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.

Soluzione

Switch to desktopCambia al desktop per esercitarti nel mondo realeContinua da dove ti trovi utilizzando una delle opzioni seguenti
Tutto è chiaro?

Come possiamo migliorarlo?

Grazie per i tuoi commenti!

Sezione 2. Capitolo 4
single

single

some-alt