# Golang : Generate multiplication table from an integer example

Tags : golang math multiplication-table education

My son is 6 years old now and it is about the right time to expose him to some basic programming and math beyond simple plus and minus. Right now he is learning to code in Golang(easier to grasp) and a little bit of Java(he is having a hard time understanding).

**NOTE** : While it is good to be able to instruct a computer to generate multiplication table, but I still hope that he is able to memorize the multiplication table from 1 to 12 as he progresses in his education.

Here you go!

```
package main
import (
"fmt"
)
func main() {
var i int
fmt.Print("Enter an integer to generate the multiplication table : ")
fmt.Scanln(&i)
for n := 1; n <= 12; n++ {
fmt.Println(i, " X ", n, " = ", i*n)
}
}
```

Sample output:

Enter an integer to generate the multiplication table : 12

12 X 1 = 12

12 X 2 = 24

12 X 3 = 36

12 X 4 = 48

12 X 5 = 60

12 X 6 = 72

12 X 7 = 84

12 X 8 = 96

12 X 9 = 108

12 X 10 = 120

12 X 11 = 132

12 X 12 = 144

#### See also : Golang : Math pow(the power of x^y) example

Tags : golang math multiplication-table education

##### By Adam Ng(黃武俊)

IF you gain some knowledge or the information here solved your programming problem. Please consider donating to the less fortunate or some charities that you like. Apart from donation, planting trees, volunteering or reducing your carbon footprint will be great too.

#### Advertisement

#### Tutorials

+13k Golang : Convert an image file to []byte

+5.7k Golang : Calculate entire request body length during run time

+16.1k Golang : Detect (OS) Operating System

+2.7k Golang : Combine slices but preserve order example

+1.7k Golang : How to calculate the distance between two coordinates using Haversine formula

+2.5k Golang : Ordinal and Ordinalize a given number to the English ordinal numeral

+8.5k Golang : How to get time from unix nano example

+2.7k Golang : Count leading or ending zeros(any item of interest) example

+3.9k PHP : Get coordinates latitude/longitude from string

+10.9k Golang : Get time.Duration in year, month, week or day

+10.9k Golang : Randomly pick an item from a slice/array example

+9.6k Golang : Print leading(padding) zero or spaces in fmt.Printf?