how can I create a triangle that includes 1,12,123,1234,1235

when n=6, I want to make a pattern from 1:n, and it should printed like this(using for or while loops)
1
2 1
3 2 1
4 3 2 1
5 4 3 2 1
6 5 4 3 2 1

2 Comments

This looks like homework again.
Please stop asking the same question repeatedly. Asking the same question over and over again will not get you a better answer.

Sign in to comment.

Answers (1)

You can start with this:
n = 6;
for k=1:n
% Fill in code here for the pattern for this iteration
end
So you need to fill in the code above, using either vectorized methods or perhaps using another loop.

Categories

Find more on Loops and Conditional Statements in Help Center and File Exchange

Asked:

on 23 Dec 2015

Commented:

on 23 Dec 2015

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!