jonestheprob1150 jonestheprob1150
  • 23-05-2022
  • Computers and Technology
contestada

Write a pseudo code to print sum of all even numbers from 1 to 100

Respuesta :

notleoprobably
notleoprobably notleoprobably
  • 03-06-2022

(python) Answer:

sum = 0

for i in range 1 to 101:

 if i modulo 2 == 0:

   sum += i

print(sum)

Explanation:

first we declare the sum variable

then go through all numbers 1 through 100 (range 1 to 101 because python range does not include the last number - if we did 1 to 100 it would look at 1 to 99)

if the number is even (divide by 2, check if there's a remainder, if not it's even and we will add the number to the sum

finally print the sum

Answer Link

Otras preguntas

Evaluate and simplify 2ab-1/3e-3d
Please it’s urgent please❤️
The numbers 1, 2, ... ,10 are to be entered into the 10 boxes shown below, so that each number is used exactly once: P = (\square + \square + \square + \square
Wich of the following groups had a political outlook similar to that of populist farmers in the late 1800s
Share $100 between two personsA and B, giving a $10 more than B​
Please answer this correctly
A manufacturing machine has two processes. One of them is repeated 4 times and the second only once. The entire cycle can take no longer than 3 minutes. Which g
NEED HELP ASAP WILL GIVE YOU BRAINILESS!!
Please answer this correctly
Para ampliar uma sala quadrada, foram acrescentados 4 metros em seu comprimento e 2 metros em sua largura, conforme a figura. Qual polinômio apresenta a área de