Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Apprendre Challenge: Print Number Pyramid | Advanced Looping: Patterns, Nesting, and Pitfalls
C# Loops Practice

bookChallenge: Print Number Pyramid

Tâche

Swipe to start coding

Write a program that prints a number pyramid pattern using nested loops. Each row should contain numbers starting from 1 up to the row number, with leading spaces so that the numbers form a centered pyramid.

  • For each row from 1 to rows, print the correct number of leading spaces.
  • Print the numbers in increasing order from 1 up to the current row number, separated by spaces.
  • Each row should be printed on a new line.
  • The pyramid should be aligned as shown in the example output.

Solution

Note
Note

The output should look like that:

    1
   1 2
  1 2 3
 1 2 3 4
1 2 3 4 5
Tout était clair ?

Comment pouvons-nous l'améliorer ?

Merci pour vos commentaires !

Section 3. Chapitre 2
single

single

Demandez à l'IA

expand

Demandez à l'IA

ChatGPT

Posez n'importe quelle question ou essayez l'une des questions suggérées pour commencer notre discussion

close

Awesome!

Completion rate improved to 5.56

bookChallenge: Print Number Pyramid

Glissez pour afficher le menu

Tâche

Swipe to start coding

Write a program that prints a number pyramid pattern using nested loops. Each row should contain numbers starting from 1 up to the row number, with leading spaces so that the numbers form a centered pyramid.

  • For each row from 1 to rows, print the correct number of leading spaces.
  • Print the numbers in increasing order from 1 up to the current row number, separated by spaces.
  • Each row should be printed on a new line.
  • The pyramid should be aligned as shown in the example output.

Solution

Note
Note

The output should look like that:

    1
   1 2
  1 2 3
 1 2 3 4
1 2 3 4 5
Switch to desktopPassez à un bureau pour une pratique réelleContinuez d'où vous êtes en utilisant l'une des options ci-dessous
Tout était clair ?

Comment pouvons-nous l'améliorer ?

Merci pour vos commentaires !

Section 3. Chapitre 2
single

single

some-alt