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

2 views (last 30 days)
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
John D'Errico
John D'Errico on 23 Dec 2015
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)

James Tursa
James Tursa on 23 Dec 2015
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 Multidimensional Arrays in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!