The number rhombus pattern prints 12345 on every row and moves each row one space to the left, so the block of numbers leans like a rhombus, the number version of the rhombus star pattern.
Quick answer: Every row prints the same 1 to n. Only the indent changes: row i starts with n β i spaces, so the first row is pushed furthest right and the last row starts at the left edge.
This program is part of the Number Patterns collection.
Table of contents8 sections
Number Rhombus Pattern output
Output (n = 5):
12345 12345 12345 12345 12345

Same shape, other characters: the Rhombus Star Pattern program draws this same outline with different characters. Putting them side by side shows which part of the loop decides the shape and which part decides what is printed.
How the number rhombus pattern works
A rhombus is a square that has been pushed sideways. The rows are identical, so the inner loop that prints 1 to n never changes; the slant comes entirely from the spaces in front. Because the indent drops by exactly one each row, every column of digits forms a straight diagonal line.
- Run the outer loop for
ifrom1ton, one row per pass. - Print
n β ispaces. - Print
nnumbers (valuej). - Move to the next line.
Key takeaways
- All rows are the same: 1 to
n. - The leading spaces
n β icreate the slant. - Each digit forms a diagonal line down to the left.
- Using
i β 1spaces instead makes the rhombus lean the other way.
Number Rhombus Pattern in C
#include <stdio.h>
int main(void) {
int n = 5;
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= n - i; j++)
printf(" ");
for (int j = 1; j <= n; j++)
printf("%d", j);
printf("\n");
}
return 0;
}Number Rhombus Pattern in C++
#include <iostream>
using namespace std;
int main() {
int n = 5;
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= n - i; j++)
cout << " ";
for (int j = 1; j <= n; j++)
cout << j;
cout << endl;
}
return 0;
}Number Rhombus Pattern in Java
public class NumberRhombus {
public static void main(String[] args) {
int n = 5;
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= n - i; j++)
System.out.print(" ");
for (int j = 1; j <= n; j++)
System.out.print(j);
System.out.println();
}
}
}Number Rhombus Pattern in Python
n = 5
for i in range(1, n + 1):
for j in range(1, n - i + 1):
print(" ", end="")
for j in range(1, n + 1):
print(j, end="")
print()Time and space complexity
The program prints one character for each position in the pattern, so for n rows it runs in O(nΒ²) time. It only needs a few loop variables, so the extra memory is O(1).
Frequently asked questions
How do I make it lean to the right?
Print i β 1 spaces instead of n β i. The first row then starts at the left edge and each row moves one step right, like the mirrored rhombus.
Can every row repeat its row number instead?
Yes. Print i instead of j: 11111, 22222 and so on, still slanted.
Why does every column form a diagonal?
Each row is the same five digits, and each row starts one column further left. So the 1 of row 2 sits one place left of the 1 of row 1, and the same goes for every digit. Following one digit down the rows traces a straight line down to the left.
How do I make a hollow number rhombus?
Print j only when i == 1, i == n, j == 1 or j == n, and a space otherwise, keeping the same indent.






