Go Program to Print Right Triangle of Consecutive Rows Numbers

Write a Go program to print the right triangle pattern of consecutive row numbers using for loop.

package main

import "fmt"

func main() {

	var i, j, row, val int

	fmt.Print("Enter Right Triangle of Consecutive Row Pattern Rows = ")
	fmt.Scanln(&row)

	fmt.Println("Right Triangle of Consecutive Row Numbers Pattern")

	for i = 1; i <= row; i++ {
		val = i
		for j = 1; j <= i; j++ {
			fmt.Printf("%d ", val)
			val = val + row - j
		}
		fmt.Println()
	}
}
Go Program to Print Right Triangle of Consecutive Rows Numbers

About Suresh

Suresh is the founder of TutorialGateway and a freelance software developer. He specialized in Designing and Developing Windows and Web applications. The experience he gained in Programming and BI integration, and reporting tools translates into this blog. You can find him on Facebook or Twitter.