J-J - 5 months ago 18

C++ Question

Answer

The number of elements to display in the leftmost *n* columns is exactly:

So, the numbers in the first row form the A000124 integer sequence.

Therefore, you can just add the row index to respective value of the sequence, and print it only when row index is not greater than column index.

```
#include <iostream>
using namespace std;
int main() {
int n;
cin >> n;
for(int i = 0; i < n; ++i) {
for(int j = 0; j < n; ++j) {
if(i <= j) {
cout << j*(j+1)/2+1 + i;
}
cout << '\t';
}
cout << endl;
}
return 0;
}
```