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

What does this tailrec function compute for `mystery(5)`, and will it be optimized into a loop?

tailrec fun mystery(n: Int, acc: Int = 1): Int = if (n <= 1) acc else mystery(n - 1, acc * n) val result = mystery(5)