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

Please..I really need help with this question..SOMEONE SEND HELP!!
Two identical daughter cell result from mitosis and cytokinesis. In what ways are they " identical"?
Volume: 72 ft3 Find the missing dimension. Round to the nearest tenth.
one sixth of thirty-six hundredths is less than two-tenths less than four
find the product of 5 1/2 and 1/8
What is the term for different “jobs” that different cells perform in a multicellular organism? A. functions B. systems C. levels D. contractions
highest mountain range in the middle east
for what value of x is the value of f(x) = 4x - 2 equal to 18?
P = (20 + 0.5x) + 0.15(20 + 0.5x) Jennifer wants to purchase a book but only has $62.10 to spend. What is the maximum number of pages she can have in her book
What is the ninth term of the arithmetic sequence defined by the rule below? A(n)= -14+(n-1)(2)