Multiplication & addition tables to print out

If you want to print a multiplication or addition tables in Go console, this is how.

This is how you print out the multiplication and addition tables in Golang.


func Multiply() {
    for i := 1; i < 10; i++ {
        fmt.Printf("Multiplication table: %v\n", i)
        for j := 1; j < 10; j++ {
            a := j * i
            fmt.Printf("%v * %v = %v\n", i, j, a)
        }
    }
}

func Additioning() {
    for i := 0; i < 11; i++ {
        fmt.Printf("Additioning table: %v\n", i)
        for j := 0; j < 10; j += 1 {
            a := j + i
            fmt.Printf("%v + %v = %v\n", i, j, a)
        }
    }
}

You can do something like this to use it

package main

func main(){
  Additioning()
  Multiply()
}