score:6

Accepted answer

the value returned from pascal is the last expression it contains. you want it to be your evaluation of count but that's not the last thing. assignments (def, val etc) are of type unit, as you've discovered:

  def pascal(c: int, r: int): int = {

   count(r,c,1,0) // => int

   def count(r: int, c: int, countr: int, lalacount: int): int = {
    if (countr < (r + 1)) count(r,c,countr + 1, lalacount + countr)
    else (lalacount + c + 1)
   } // => unit
  }

just move count(r,c,1,0) after the def and that should fix the problem.


Related Query

More Query from same tag