Python Write a program to compute the sum of the series: 5+10+15+20+25...+n wher
ID: 3754554 • Letter: P
Question
Python Write a program to compute the sum of the series: 5+10+15+20+25...+n where n is an input. Consider that n is always valid (which means it follows the series pattern). For example, if n=40, the program sums 5+10+15+20+25+30+35+40 and displays the result 180. Python Python Python Write a program to compute the sum of the series: 5+10+15+20+25...+n where n is an input. Consider that n is always valid (which means it follows the series pattern). For example, if n=40, the program sums 5+10+15+20+25+30+35+40 and displays the result 180.Explanation / Answer
// first we declare some variable x and sum1
x = 5
sum1 = 0
// we have to enter one integer n where n is an our input, and I'm doing typecasting with integer
n = int(input("enter:"))
//while loop will run till n
while x <= n:
sum1 = sum1 + x
x = x + 5
//Display the result with sum1
print (sum1)
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.