Kotlin, Programming, Software Development, Functional Programming, Coding.
recursion — fun factorial(n: Int, accumulator: Int = 1): Int { if (n == 1) return accumulator return factorial(n - 1, n * accumulator) } In the tail-recursive version, the result of the recursive call (combined with the current operation) is passed as an accumulator. It ensures that no extra