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

If a car used 250,000 W of power to complete a race in 12 s, how much work did the car do?
What impact did the tang and Song Dynasties have on government
Please hurry this is 7th grade hon
HELP IMMEDIATELY. The Nazi party most strongly appealed to the German people because it was founded by former soldiers. blamed others for losing the war. provid
What Asian physical feature is represented by #2? A Iranian Plateau B Tibetan Plateau C Deccan Plateau D Caucus Mountains
someone help it’s timed!!!
the earth will be destroyed in 2050. change to active voice​
1. TRUE or FALSE?: America suffered it's heaviest losses when they launched a ground assault on the island of Japan in 1945. 2. TRUE or FALSE?: As they did dur
Can someone explain what the GFC is to me pls. Step by step explanation.
one of the following functions is growing at the same rate as 4²