Logic Building
# Take inputs
a = float(input("Enter first term (a): "))
r = float(input("Enter common ratio (r): "))
n = int(input("Enter number of terms (n): "))
# Calculate sum
total = 0
for i in range(n):
total += a * (r ** i)
print(f"Sum: {total}")Output
Enter first term (a): 2 Enter common ratio (r): 3 Enter number of terms (n): 4 Sum: 80.0
Sum terms of geometric progression.
Key Concepts:
- Each term = a * r^i
- Loop from 0 to n-1
- Accumulate sum