Print stars like a Triangle in GO

Print stars like a Triangle in GO Language

Source code :


package main

import "fmt"

func main() {

k := 0

for i := 1 ; i <= 5 ; i++ {

    for sp := 1; sp <= 5-i; sp++ {

           fmt.Printf("  ")
    }
        
    for k != 2*i-1 {

           fmt.Printf("* ")
           k++

    }
        k = 0

    fmt.Println()
        
}

}

Output :

        
        
        
        
        * 

Output :


                

Comments :