Add up 1 to 100 · Somar 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.
Somar 1 a 100
Some todos os números inteiros de 1 a 100 e imprima o resultado.
Este é um total acumulado: comece em 0 e some a variável do loop em cada passada. O inicializador adiciona 1 a 10, então você só precisa alterar onde o range para. Diz-se que o jovem Carl Friedrich Gauss encontrou esta resposta mentalmente pareando 1 + 100, 2 + 99 etc.
Use a for loop to add up every whole number from 1 to · até 100, then print the total once. · Use um loop for para somar todos os números inteiros de 1 a 100, depois imprima o total uma vez.
Click Run to see the output here. · Clique em Executar para ver a saída aqui.