This Python program reads two numbers a and b from the user and calculates the sum of 21 terms of a numeric series.
In this version, we assume the series starts from a and adds up 21 consecutive integers.
You can replace the formula with any custom logic to match the intended series.
def series_sum(start: int, count: int = 21) -> int:
total = 0
for i in range(start, start + count):
total += i # Replace this line with any custom series formula
return total
# Read inputs from user
a = int(input("Enter the starting number of the series: "))
b = int(input("Enter the second number (for display): ")) # symbolic use of b
result = series_sum(a)
print(f"The sum of 21 terms starting from {a} is: {result}")
The sum of 21 terms starting from 2 is: 231