0

Now this question is being written in Scala, but Scala is Java compatible. I will translate the java code into Scala.

// Write a recursive function "upto"

// that takes two Int parameters "start" and "end" and produces a "List[Int]"

// that counts DOWN from "start" to "end" (inclusive at both ends) one at

// a time. If "start < end", the empty list must be returned.

//This is what I have come up with so far. We had 10 questions, I have 9 of them done,

//just trying to figure this one out. I just need guidance on how to use the recursive

//call correctly

```
def otpu (start:Int, end:Int) : List[Int] = {
if (start < end)
List() //return empty list
else
(otpu( (start-1), 0) ) //returns 20, 19, 18, 17, 16, 15 (if upto(20, 15) entered.
}
```

Just point me in the right direction. I always have trouble grasping / defining the recursive function.

*Edited 5 Years Ago by transplantedNYr*: n/a