Print inverted full pyramid using star
Example
package main
import "fmt"
func main() {
var rows = 5
var i, j int
for i = rows; i >= 1; i-- {
for space := 1; space <= rows-i; space++ {
fmt.Print(" ")
}
for j = i; j <= 2*i-1; j++ {
fmt.Printf("* ")
}
for j = 0; j < i-1; j++ {
fmt.Printf("* ")
}
fmt.Println("")
}
}
Output
* * * * * * * * *
* * * * * * *
* * * * *
* * *
*
Most Helpful This Week
Go program to find Name Server (NS) record of a domain
How to Iterate Over a Slice in Golang?
Create and Print Multi Dimensional Slice in Golang
Modernizing Legacy Applications: Critical Tips for Organizational Upgrades
Example to compare Println vs Printf
Golang read file line by line to string
Find odd and even numbers using goroutines and channels
Golang program to generate number of slices permutations of number entered by user
Program in Go language to print Floyd's Triangle
Syntax error: unexpected <token> error in Golang