Add up 1 to 100 · Sumar de 1 a 100
Add up 1 to 100
Add every whole number from 1 to 100 and print the result.
This is a running total: start at 0 and add the loop variable on every pass. The starter adds 1 to 10, so you only need to change where the range stops. The young Carl Friedrich Gauss is said to have found this answer in his head by pairing 1 + 100, 2 + 99 and so on.
Sumar del 1 al 100
Suma todos los números enteros desde 1 hasta 100 e imprime el resultado.
Esta es una suma acumulativa: comienza en 0 y suma la variable del bucle en cada pasada. El código inicial suma de 1 a 10, por lo que solo necesitas cambiar dónde se detiene el range. Se dice que el joven Carl Friedrich Gauss encontró esta respuesta mentalmente al emparejar 1 + 100, 2 + 99 y así sucesivamente.
Use a for loop to add up every whole number from 1 to · hasta 100, then print the total once. · Utilice un bucle for para sumar cada número entero desde 1 hasta 100, y luego imprima el total una sola vez.
Click Run to see the output here. · Haz clic en Ejecutar para ver la salida aquí.