Day 6 of My 30-Day Coding Challenge on HackerRank
Day 6 was all about loops and repetition—one of the most fundamental concepts in programming.
Today’s challenge focused on generating the multiplication table of a given number using a loop.
Problem Overview
Today’s challenge focused on:
Understanding loops
Repeating tasks efficiently
Performing multiplication operations
Formatting output properly
We were given an integer n and asked to print its first 10 multiples in the format:
n x i = result
Where i ranges from 1 to 10.
My Solution
n = int(input())
for i in range(1, 11):
print(f"{n} x {i} = {n*i}")
What I Did Today
I learned how to:
Use a
forloop for repeated executionGenerate multiplication tables dynamically
Format strings neatly using f-strings
Combine logic with loops
Here’s the logic I followed:
1. Read integer n
2. Start loop from 1 to 10
3. Multiply n with current loop value
4. Print in required format
5. Repeat until 10
What I Learned
Today’s key takeaways:
Loops help automate repetitive tasks
forloops are useful when the number of iterations is knownOutput formatting improves readability
Multiplication tables are a great beginner example of loops
Challenges Faced
Understanding loop range values
Making sure output format matches exactly
Avoiding spacing mistakes in print statements
Why This Problem Matters
This problem helps in understanding:
Iteration in programming
Mathematical automation using loops
Pattern-based output generation
Loops are used everywhere—from simple tasks to complex algorithms.
🧪 Sample Run
Input:
2
Output:
2 x 1 = 2
2 x 2 = 4
2 x 3 = 6
2 x 4 = 8
2 x 5 = 10
2 x 6 = 12
2 x 7 = 14
2 x 8 = 16
2 x 9 = 18
2 x 10 = 20
Plan for Day 7
- Improve problem-solving speed
💬 Final Thoughts
Day 6 was a simple but important reminder that loops are incredibly powerful.
Instead of writing the same code again and again, loops help us solve problems efficiently and cleanly.
Let’s keep the momentum going
