To print a right half pyramid pattern in Swift, you can use nested loops to control the number of rows and columns printed.
In this example,
n
to represent the number of rows in the pyramid.let n = 5
for i in 1...n {
var row = ""
for _ in 1...i {
row += "*"
}
print(row)
}
* ** *** **** *****
In this tutorial, we learned How to print Right Half Pyramid Pattern in Swift language with well detailed examples.