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

Why does the compiler reject `tailrec` on this function with a warning that the recursive call is not in a tail position?

tailrec fun sum(n: Int): Int { if (n == 0) return 0 return n + sum(n - 1) }