Respuesta :
Answer:
public static String repeat(String text, int repeatCount) {
if(repeatCount < 0) {
throw new IllegalArgumentException("repeat count should be either 0 or a positive value");
}
if(repeatCount == 0) {
return "";
} else {
return text + repeat(text, repeatCount-1);
}
}
Explanation:
Here repeatCount is an int value.
at first we will check if repeatCount is non negative number and if it is code will throw exception.
If the value is 0 then we will return ""
If the value is >0 then recursive function is called again untill the repeatCount value is 0.
The recursive method called repeat in this exercise will be implemented using the Kotlin programming language
fun repeat (s:String, n: Int ) {
repeat(n) {
println("s")
}
}
In the above code, the Kotlin repeat inline function was used to archive the multiple output of the desired string, here is a documentation of how the repeat keyword/function works inline
fun repeat(times: Int, action: (Int) -> Unit)
//Executes the given function action specified number of times.
Learn more about Recursive methods:
https://brainly.com/question/11316313