/**
 * Calculates the division of dancers into groups using nested loops.
 *
 * @param dancerCount Total number of dancers.
 * @param groupCount Total number of groups.
 * @param maxIterations Maximum number of iterations.
 * @return The optimal division of dancers into groups.
 * @throws IllegalArgumentException If any of the arguments is less than 1.
 */
fun nestedLoopDivision(dancerCount: Int, groupCount: Int, maxIterations: Int): Int {

    if (dancerCount < 1 || groupCount < 1 || maxIterations < 1) {
        throw IllegalArgumentException("All arguments must be greater than zero.")
    }

    var optimalDivision = 0

    for (i in 1..dancerCount) {
        for (j in 1..groupCount) {
            if (i % j == 0) {
                for (k in 1..maxIterations) {
                    optimalDivision += i / j
                }
            }
        }
    }

    return optimalDivision
}
/**
 * Calculates the division of dancers into groups using nested loops.
 *
 * @param dancerCount Total number of dancers.
 * @param groupCount Total number of groups.
 * @param maxIterations Maximum number of iterations.
 * @return The optimal division of dancers into groups.
 * @throws IllegalArgumentException If any of the arguments is less than 1.
 */
fun nestedLoopDivision(dancerCount: Int, groupCount: Int, maxIterations: Int): Int {
/**
 * Calculates the division of dancers into groups using nested loops.
 *
 * @param dancerCount Total number of dancers.
 * @param groupCount Total number of groups.
 * @param maxIterations Maximum number of iterations.
 * @return The optimal division of dancers into groups.
 * @throws IllegalArgumentException If any of the arguments is less than 1.
 */
fun nestedLoopDivision(dancerCount: Int, groupCount: Int, maxIterations: Int): Int {

    if (dancerCount < 1 || groupCount < 1 || maxIterations < 1) {
        throw IllegalArgumentException("All arguments must be greater than zero.")
    }

    var optimalDivision = 0

    for (i in 1..dancerCount) {
        for (j in 1..groupCount) {
            if (i % j == 0) {
                for (k in 1..maxIterations) {
                    optimalDivision += i / j
                }
            }
        }
    }

    return optimalDivision
}