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 to solve 24x = 48
please help! what is this answer?? answer asap
Tiffany, Lori, and Mika are practicing for an egg-tossing contest. The distance from Tiffany to Lori is 17 inches. The distance from Lori to Mika is 32 inches.
"if an organism's dna contains 20% adenine nucleotides, what percentage of its dna is composed of guanine nucleotides?"
The equation h(t)=−16t2+19t+110 gives the height of a rock, in feet, t seconds after it is thrown from a cliff. What is the initial velocity when the rock is
Individuals are allowed to give the largest contributions to ___.
In the 1944 case korematsu v. united states, the supreme court ruled that wartime conditions justified the
what sugihara is called a hero
The South controlled the area around Fort Sumter, but not the fort itself. Lincoln knew they needed help, but did not want to start a war. What did Lincoln choo
If the grass contains 100,000 kcal of energy, how much energy will a fox obtain from eating a bird?