kwthrth89
kwthrth89 kwthrth89
  • 18-06-2021
  • Computers and Technology
contestada

find the summation of even number between (2,n)​

Respuesta :

MrRoyal
MrRoyal MrRoyal
  • 24-06-2021

Answer:

The program in python is as follows:

n = int(input("n: "))

sum = 0

for i in range(2,n+1):

   if i%2 == 0:

       sum+=i

print(sum)

Explanation:

This gets input n

n = int(input("n: "))

This initializes sum to 0

sum = 0

This iterates through n

for i in range(2,n+1):

This checks if current digit is even

   if i%2 == 0:

If yes, take the sum of the digit

       sum+=i

Print the calculated even sum

print(sum)

Answer Link

Otras preguntas

Is anyone willing enough to answer this question
help me pleaseeeeeeeeeeeeeeeeeeeeeeeeeee
Signs that may indicate a resident is in pain include:
Juanita estå aburrida dejugar a las cartas, pero Miguel estå muy contento porque le estå ganando. EI gran estreno Imagina que eres un(a) reportero/a de espectåc
When simplified, the value of the expression (15 - 11)^2 + square root 64 ÷ 4 is equal to _____. 24 10 18 4
The boxed sweets store sells bulk boxes of candy for $20 per box and bulk boxes of gum for $14 per box. How many boxes of candy needs to be combined with 10 box
What does the A in the acronym SMART stand for?
What month did mr. prizada go back to his home
The Following do not need sun's energy EXCEPTa. rotating clockb. evening torch c. plowing mand. winding stairways​
Define state of matter!!​