Ad
  • Custom User Avatar

    It is a nearly perfect solution.
    You can be a bit concise by using the reduce method instead, because it uses the first value which is identical here.

    fun fact(n: Int): Int {
        return (1..n).reduce { acc, i -> acc * i }
    }