Triangle pattern program in swift using asterisk

Triangle pattern program in swift using asterisk . This is a basic set of programs in every programming language to print the pattern. This is helps you to print the triangle pattern program in swift * programming language

func pattern(_ int : Int)
{
for i in 1...int
{
print(String.init(repeating: " ", count: int-i) + String.init(repeating: "*", count: 2*i - 1))
}
}
pattern(5)

 

Output:
         *
       **
     ***
   ****
******