Go Program to Print Left Pascals Number Triangle

Write a Go program to print the left pascals number triangle using for loop.

package main

import "fmt"

func main() {

	var i, j, k, row int

	fmt.Print("Enter Left Pascals Number Pattern Rows = ")
	fmt.Scanln(&row)

	fmt.Println("Left Pascals Number Triangle Pattern")

	for i = 1; i <= row; i++ {
		for j = i; j < row; j++ {
			fmt.Printf(" ")
		}
		for k = 1; k <= i; k++ {
			fmt.Printf("%d", k)
		}
		fmt.Println()
	}

	for i = row; i >= 1; i-- {
		for j = i; j <= row; j++ {
			fmt.Printf(" ")
		}
		for k = 1; k < i; k++ {
			fmt.Printf("%d", k)
		}
		fmt.Println()
	}
}
Go Program to Print Left Pascals Number Triangle

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.