how can I create a triangle that includes 1,12,123,1234,1235
Show older comments
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
James Tursa
on 23 Dec 2015
This looks like homework again.
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.
Answers (1)
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 Loops and Conditional Statements 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!