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

How many moles are there in 545g of Fe2O3 ?
a square has a side lengths of 9, use the pythagorean theorem to find the length of the diagonal
Simplify the expression 3a+5b+2c+8b by combining like terms
The nile river is 6,690 kilometers long. This is 1,160 kilometers longer than the Yangtze River. How long is the Yangtze River
Read Shakespeare's "Sonnet 130.” My mistress' eyes are nothing like the sun; Coral is far more red, than her lips red: If snow be white, why then her breasts ar
Which basic materials do artists use to make a fresco A Colored chalks and plaster B Paint and plaster C Tesserae and grout
Fill in the blank with the correct conjunction of the verb aprenderElla ___ ingles.A) aprendemos B) aprendeC) aprenden D) aprendo
Tell me the process of verb conjugation in present tense. Give me an example with a Spanish sentence.
According to Washington what impact will discrimination have
Solve for x. 6x-10≤8 or 1/3 x+6>12