This Python program reads two integers a and b from the user.
It calculates the sum of a mathematical series between those two numbers.
In this version, we assume the series is simply the sum of all integers from a to b, but you can easily modify the formula to fit any custom series.
def series_sum(a: int, b: int) -> int:
total = 0
for i in range(a, b + 1):
total += i # Replace this line with any custom series formula
return total
# Read inputs from user
a = int(input("Enter the first number: "))
b = int(input("Enter the second number: "))
result = series_sum(a, b)
print(f"The sum of the series from {a} to {b} is: {result}")
The sum of the series from 9 to 11 is: 30
- The user enters two numbers
- The program uses a loop to calculate the sum of values between them
- You can replace the formula inside the loop to compute factorials, powers, or any other series
- The final result is printed