Skip to main content
Journey Uncommon Logo
JourneyUncommon
mediumKotlintailrec functionsSingle-choice MCQ

Why does the Kotlin compiler refuse to optimize this function even though `tailrec` is present?

tailrec fun factorial(n: Int, acc: Int = 1): Int { if (n <= 1) return acc return n * factorial(n - 1, acc) }