/**
 * Given the number of rows and columns, generate a multiplication table.
 *
 * @param rows an integer representing the number of rows in the table
 * @param cols an integer representing the number of columns in the table
 * @return A nested list representing the multiplication table, where each element at position [i][j]
 * stores the product of (i+1) and (j+1).
 */
fun multiplicationTable(rows: Int, cols: Int): List<List<Int>> {

    val table = Array(rows) { IntArray(cols) }

    // Fill the table with the products of the row and column numbers
    for (i in 0 until rows) {
        for (j in 0 until cols) {
            table[i][j] = (i + 1) * (j + 1)
        }
    }

    return table.map { it.toList() }
}
/**
 * Given the number of rows and columns, generate a multiplication table.
 *
 * @param rows an integer representing the number of rows in the table
 * @param cols an integer representing the number of columns in the table
 * @return A nested list representing the multiplication table, where each element at position [i][j]
 * stores the product of (i+1) and (j+1).
 */
fun multiplicationTable(rows: Int, cols: Int): List<List<Int>> {
/**
 * Given the number of rows and columns, generate a multiplication table.
 *
 * @param rows an integer representing the number of rows in the table
 * @param cols an integer representing the number of columns in the table
 * @return A nested list representing the multiplication table, where each element at position [i][j]
 * stores the product of (i+1) and (j+1).
 */
fun multiplicationTable(rows: Int, cols: Int): List<List<Int>> {

    val table = Array(rows) { IntArray(cols) }

    // Fill the table with the products of the row and column numbers
    for (i in 0 until rows) {
        for (j in 0 until cols) {
            table[i][j] = (i + 1) * (j + 1)
        }
    }

    return table.map { it.toList() }
}