using System;
namespace MyCompiler {
class Program {
public static void Main(string[] args) {
int rowNumber = 5;
trianglePattern(rowNumber);
}
static void trianglePattern(int rowVal){
//Number of rows in the pattern
for(int row=1; row <= rowVal; row++){
int spaces = rowVal - row;
//Print total number of spaces
for(int spa=0; spa < spaces; spa++){
Console.Write(" ");
}
//number of column in each row in left side
for(int col = 1; col <= row; col++){
Console.Write(col + " ");
}
//number of column in each row in right side
for(int col = row-1; col >= 1; col--){
Console.Write(col + " ");
}
//when one line is printed we need to add one new line
Console.WriteLine(" ");
}
}
}
}
To embed this project on your website, copy the following code and paste it into your website's HTML: