...

/

Solution Review: Tail Recursion

Solution Review: Tail Recursion

In the following lesson, we will go over the solution of the challenge: Tail Recursion.

Task

In this challenge, you had to create a tail-recursive factorial function.

Solution

A skeleton of the function was already provided for you. Let’s look it over.

def factorial(x: Int): Int = {
  def loop(accumulator: Int, x: Int): Int = {
    

  }
  loop(1,x)
}

As before, factorial ...