This Python program generates a number series where:
- The first term is fixed as 1
- The second term is entered by the user
- From the third term onward, each term is the average of the two previous terms
The program displays the first n terms of the series.
n = int(input("Enter number of terms to display: "))
second = float(input("Enter the second term: "))
series = [1, second]
for i in range(2, n):
next_term = (series[i - 1] + series[i - 2]) / 2
series.append(next_term)
print("Generated series:")
for i, value in enumerate(series):
print(f"Term {i + 1}: {value}")
Enter number of terms to display: 6
Enter the second term: 5
Generated series:
Term 1: 1.0
Term 2: 5.0
Term 3: 3.0
Term 4: 4.0
Term 5: 3.5
Term 6: 3.75
- The first term is fixed as 1
- The second term is entered manually
- From the third term onward, each term is calculated as the average of the previous two
- The series is stored in a list and printed term by term