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

Which list represents the classification of the elements nitrogen, neon, magnesium, and silicon, respectively?
solve and check |2p+7|=9
A child with a bloated belly ,thin hair, and an inability to concentrate may be suffering from malnutrition
In which quadrant does 3(cos(5pi/3) + isin(5pi/3) lie?
With inductive reasoning you begin with data and then determine the general conclusion.
A feature that distinguishes ribose from deoxyribose is the absence of an oh at the:
The triplet codes in dna needed to specify a specific polypeptide chain are found in the
Help with geometry hw
Section 10-5 find the equation of a hyperbola with the given values, foci, and vertices. assume that the transverse axis is horizontal
Which amendment banned slavery in america? why did the confederate commander surrender at vicksburg? what was the importance of the union capturing vicksburg? w