Lucas Series
Generate Lucas series (2, 1, 3, 4, 7, ...).
IntermediatePhase 6 - Category 4: Mathematical CombinationsExample 9 of 10
lucas-series.py
1# Take n2n = int(input("Enter number of terms: "))34# Generate Lucas series5if n <= 0:6 print("Invalid input")7elif n == 1:8 print("2")9elif n == 2:10 print("2 1")11else:12 a, b = 2, 113 print(a, b, end=" ")14 for i in range(2, n):15 c = a + b16 print(c, end=" ")17 a, b = b, c18 print()
Output
Enter number of terms: 8 2 1 3 4 7 11 18 29
What's going on
Lucas series: starts with 2, 1.
Key Concepts:
Start with 2, 1
Each next = sum of previous two
Similar to Fibonacci
🔗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