why does eclipse complain "recursive method loop needs result type"?
<p>I am editing following code in eclipse but it complains that "recursive method loop needs result type", so what's the error? Thanks.</p>

<pre><code>package week2

object exercise {
  def factorial(n: Int): Int = {
    def loop(acc: Int, n: Int) =
      if (n == 0) acc
      else loop(acc * n, n - 1)

    loop(1, n)
  }

  factorial(4)
}
</code></pre>

<p>Thanks for the answer. Yes, I missed something here. The correct is:</p>

<pre><code>package week2

object exercise {
  def factorial(n: Int): Int = {
    def loop(acc: Int, n: Int): Int =
      if (n == 0) acc
      else loop(acc * n, n - 1)

    loop(1, n)
  }                                               //&gt; factorial: (n: Int)Int

  factorial(4)                                    //&gt; res0: Int = 24
}
</code></pre>