Golang Program to print Triangle of Numbers
Example
package main
import "fmt"
func main() {
var rows = 5
for i := 1; i <= rows; i++ {
for j := 1; j <= i; j++ {
fmt.Printf("%d ", j)
}
fmt.Println()
}
}
Output
1
1 2
1 2 3
1 2 3 4
1 2 3 4 5
Most Helpful This Week
How do you handle HTTP client server logging in Go?
Undefined <variable/function> error in Golang
Send and Receive values from Channel
Top Programming Languages Behind Blockchain App Development
Example to compare Println vs Printf
Launches 10 Goroutines and each goroutine adding 10 values to a Channel