编辑代码

object MultiplicationTable {
  def main(args: Array[String]): Unit = {
    printMultiplicationTable()
  }

  def printMultiplicationTable(): Unit = {
    for (i <- 1 to 9) {
      for (j <- 1 to 9) {
        if (j <= i) {
          val result = i * j
          print(s"$i * $j = $result\t")
        }
      }
      println()  // 换行
    }
  }
}