Geometric Series Sum
Calculate a + ar + ar² + ... + arⁿ.
IntermediatePhase 6 - Category 4: Mathematical CombinationsExample 5 of 10
geometric-series-sum.py
1# Take inputs2a = float(input("Enter first term (a): "))3r = float(input("Enter common ratio (r): "))4n = int(input("Enter number of terms (n): "))56# Calculate sum7total = 08for i in range(n):9 total += a * (r ** i)1011print(f"Sum: {total}")
Output
Enter first term (a): 2 Enter common ratio (r): 3 Enter number of terms (n): 4 Sum: 80.0
What's going on
Sum terms of geometric progression.
Key Concepts:
Each term = a * r^i
Loop from 0 to n-1
Accumulate sum
🔗Related Content
- 📖
Phase 6 - Learn Concepts
Review Phase 6 concepts and explanations
- 📝
Phase 6 - Quiz
Test your Phase 6 understanding with quiz questions
- 💻
Phase 6 - All Practice Problems
Explore all practice problems for Phase 6
- 🎓
Master Your Logic Building - Complete Course
Browse all phases and tutorials
- 🧠
Logic Building Overview
Learn about the complete logic building curriculum