Go Program to Print Inverted Right Triangle Number Pattern

Write a Go Program to Print Inverted Right angled Triangle Number Pattern. In this Golang Inverted Right Triangle Number example, the first for loop iterates from end to start. The second for loop (for j = i; j > 0; j–) iterates from i to 0. Within the loop, we print 1’s.

package main

import "fmt"

func main() {

    var i, j, rows int

    fmt.Print("Enter Rows for Inverted Right Triangle Number Pattern = ")
    fmt.Scanln(&rows)

    fmt.Println("\nInverted Right Angled Triangle Number Pattern")
    for i = rows; i > 0; i-- {
        for j = i; j > 0; j-- {
            fmt.Print("1 ")
        }
        fmt.Println()
    }
}
Go Program to Print Inverted Right Triangle Number Pattern 1

This Golang program allows entering a number and prints the Inverted Right angled Triangle pattern of that number.

package main

import "fmt"

func main() {

    var i, j, rows, num int

    fmt.Print("Enter Rows for Inverted Right Triangle Number Pattern = ")
    fmt.Scanln(&rows)

    fmt.Print("Inverted Right Triangle NUmber = ")
    fmt.Scanln(&num)

    fmt.Println("\nInverted Right Angled Triangle Number Pattern")
    for i = rows; i > 0; i-- {
        for j = i; j > 0; j-- {
            fmt.Printf("%d ", num)
        }
        fmt.Println()
    }
}
Enter Rows for Inverted Right Triangle Number Pattern = 8
Inverted Right Triangle NUmber = 9

Inverted Right Angled Triangle Number Pattern
9 9 9 9 9 9 9 9 
9 9 9 9 9 9 9 
9 9 9 9 9 9 
9 9 9 9 9 
9 9 9 9 
9 9 9 
9 9 
9 

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.