/**
 * Write a function that takes an integer n as input and returns a nested tuple in the form:
 *
 * ((n, n-1, n-2, ..., 1), ((n-1, n-2, ..., 1), (n-2, ..., 1), ..., (1,)))
 *
 * You cannot use loops or list comprehensions.
 *
 * @param n A positive integer representing the number of nested tuples.
 * @return The nested tuple as described.
 */
fun nestedTuples(n: Int): Pair<List<Int>, List<List<Int>>> {

    if (n == 1) {
        return Pair(listOf(1), listOf())
    }

    val previousTuple = nestedTuples(n - 1)
    var currentTuple = listOf<Int>()
    for (i in n downTo 1) {
        currentTuple += listOf(i) + previousTuple.first[i - 1]
    }

    return Pair(previousTuple.first + currentTuple, previousTuple.second + listOf(currentTuple))
}
/**
 * Write a function that takes an integer n as input and returns a nested tuple in the form:
 *
 * ((n, n-1, n-2, ..., 1), ((n-1, n-2, ..., 1), (n-2, ..., 1), ..., (1,)))
 *
 * You cannot use loops or list comprehensions.
 *
 * @param n A positive integer representing the number of nested tuples.
 * @return The nested tuple as described.
 */
fun nestedTuples(n: Int): Pair<List<Int>, List<List<Int>>> {
/**
 * Write a function that takes an integer n as input and returns a nested tuple in the form:
 *
 * ((n, n-1, n-2, ..., 1), ((n-1, n-2, ..., 1), (n-2, ..., 1), ..., (1,)))
 *
 * You cannot use loops or list comprehensions.
 *
 * @param n A positive integer representing the number of nested tuples.
 * @return The nested tuple as described.
 */
fun nestedTuples(n: Int): Pair<List<Int>, List<List<Int>>> {

    if (n == 1) {
        return Pair(listOf(1), listOf())
    }

    val previousTuple = nestedTuples(n - 1)
    var currentTuple = listOf<Int>()
    for (i in n downTo 1) {
        currentTuple += listOf(i) + previousTuple.first[i - 1]
    }

    return Pair(previousTuple.first + currentTuple, previousTuple.second + listOf(currentTuple))
}