// An alternate O(n^2) solution. I feel like you could make this O(n log n) somehow if you stored previous multiplication pairs in some data structure.
int[] numbers = { 1, 2, 3, 4, 5, 6, 7, 8, 9 };
int colCount = 1;
int rowCount = 1;
int innerCount = 0;
while (rowCount != numbers.length + 1) {
System.out.printf("%4d", numbers[innerCount++] * colCount);
if (innerCount == numbers.length) {
innerCount = 0;
colCount++;
rowCount++;
System.out.println("");
}
}