Print Multiples of 5 Up to N
Print all multiples of 5 from 5 to n.
BeginnerPhase 2 - Level 1: Basic LoopingExample 12 of 14
print-multiples-of-5-up-to-n.py
1# Take n as input2n = int(input("Enter n: "))34# Print multiples of 55print("Multiples of 5:")6for i in range(5, n + 1, 5):7 print(i, end=" ")8print()
Output
Enter n: 25 Multiples of 5: 5 10 15 20 25
What's going on
Use range with step 5 to get multiples.
Key Concepts:
range(5, n+1, 5) gives multiples of 5
Step size 5 skips non-multiples
Efficient way to get multiples
🔗Related Content
- 📖
Phase 2 - Learn Concepts
Review Phase 2 concepts and explanations
- 📝
Phase 2 - Quiz
Test your Phase 2 understanding with quiz questions
- 💻
Phase 2 - All Practice Problems
Explore all practice problems for Phase 2
- 🎓
Master Your Logic Building - Complete Course
Browse all phases and tutorials
- 🧠
Logic Building Overview
Learn about the complete logic building curriculum