In this code, n=6 intialised used as refrence and mark the number of rows. In 2nd line we have for loop "i" which will be executed 6 times, then we have two nested for loops in first loops we are printing spaces which goes from (0 to (n-i-1)) e.g (6-0-1 = 5 ) , so that means 5 spaces will be printed on first row and when that is executed 2nd nested loop will come into play which is responsible for printing "#" first row -> " #" 2nd row -> " ##" as value of i increases spaces will be decreasing and number of "#" will be increasing with each row.
OR