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 comentarios

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.

Iniciar sesión para comentar.

Respuestas (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.

Categorías

Más información sobre Loops and Conditional Statements en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

el 23 de Dic. de 2015

Comentada:

el 23 de Dic. de 2015

Community Treasure Hunt

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

Start Hunting!

Translated by