Multiplication Table Grid - Problem
Generate an N×N multiplication table and display it in a neatly aligned grid format with row and column headers.
The table should show the product of each row number (1 to N) with each column number (1 to N). Format the output so that all numbers are properly aligned in columns, making it easy to read.
For example, a 4×4 multiplication table would show products from 1×1 to 4×4 arranged in a grid with headers.
Input & Output
Example 1 — Small Table
$
Input:
n = 3
›
Output:
1 2 3
1 1 2 3
2 2 4 6
3 3 6 9
💡 Note:
A 3×3 multiplication table with row and column headers. Each cell shows the product of row number × column number, properly aligned.
Example 2 — Larger Table
$
Input:
n = 4
›
Output:
1 2 3 4
1 1 2 3 4
2 2 4 6 8
3 3 6 9 12
4 4 8 12 16
💡 Note:
A 4×4 multiplication table. Notice how larger numbers (like 16) maintain proper column alignment throughout the grid.
Example 3 — Minimal Case
$
Input:
n = 1
›
Output:
1
1 1
💡 Note:
The smallest possible multiplication table: just 1×1 = 1 with proper headers and formatting.
Constraints
- 1 ≤ n ≤ 12
- Output must be properly aligned in columns
- Include row and column headers
Visualization
Tap to expand
💡
Explanation
AI Ready
💡 Suggestion
Tab
to accept
Esc
to dismiss
// Output will appear here after running code