/**
 * Takes a string and a number. Returns a new string obtained by repeating each character of the input string a number
 * of times equal to its position in the string modulus the input number.
 *
 * @param text The input string.
 * @param num The input number.
 * @return The modified string.
 */
fun modulusAndStringLoop(text: String, num: Int): String {

    var result = ""
    for ((index, char) in text.withIndex()) {
        result += char.toString().repeat(index % num)
    }
    return result
}

// Example usage
/**
 * Takes a string and a number. Returns a new string obtained by repeating each character of the input string a number
 * of times equal to its position in the string modulus the input number.
 *
 * @param text The input string.
 * @param num The input number.
 * @return The modified string.
 */
fun modulusAndStringLoop(text: String, num: Int): String {
/**
 * Takes a string and a number. Returns a new string obtained by repeating each character of the input string a number
 * of times equal to its position in the string modulus the input number.
 *
 * @param text The input string.
 * @param num The input number.
 * @return The modified string.
 */
fun modulusAndStringLoop(text: String, num: Int): String {

    var result = ""
    for ((index, char) in text.withIndex()) {
        result += char.toString().repeat(index % num)
    }
    return result
}

// Example usage