07/09/2022, 9:31 AM
Kotlin. Function does not exit recursion after return I need to decompose the number l into prime factors. For this I use recursion. And when l = 1, the function must exit their recursion and return the string in which the prime factors are located, however, the function continues to work and already according to a principle incomprehensible to me. Please explain what is the problem with my code? fun factors(l: Int): String { return if (l == 1) { answer } else { for (i in 2..l) { if (l % i == 0) {...