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

Divide 9x^2-21x-20 by x-1 --> My answer is 9x^2-12-32/x-1. Would someone tell me if I got this right? I used the synthetic division method in order to get my
According to present Obama what were the long term affects of the Montgomery bus boycott?
Which social structure did the Aztecs and the Incas have in common?
Which of the following statement is a fallacy of logos? A- A person should be quit in hospital hallways. This is a hospital hallway; I should be quit. B- An inj
Which verb agrees in number with its subject? Either my cousins or my sister __________ out at the fair today. A. is helping B. are helping C.
What could be the last digit of the composite number? All digits are:
When are estate taxes levied
What is the slope A. Undefined B. 0
After returning to South Africa from Algeria in 1964, Nelson Mandela was
is 3/16 of a mile less than 3/4 of a mile?