CSharp · Console
using System;
public class Program
{
public static void Main()
{
staircase(10);
}
// Complete the staircase function below.
static void staircase(int n) {
// Find number of spaces needed
string space = "";
for (int i = 1; i < n; i++) {
space += " ";
}
string hash = "#";
for (int j = 0; j < n; j++) {
var tempSpace = space.Substring(0, space.Length - j);
Console.Write($"space: {space.Length} | ");
Console.Write($"tempSpace: {tempSpace.Length} | ");
Console.Write(space + hash);
Console.Write(Environment.NewLine);
hash += "#";
}
}
}