Triangle pattern program in Swift

Traingle pattern program in swift programming language from the basics to understand the pattern program using the numbers to print the pattern programs

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

Output:

       1                                                                                                                   

      111                                                                                                                     

     11111                                                                                                                    

    1111111                                                                                                                   

   111111111                                                                                                                  

  11111111111                                                                                                                 

 1111111111111                                                                                                                

111111111111111