Hey,
Recursion is when a function makes a call to itself. When we place this call as the last action performed in the function, we can call the function tail-recursive.
Here is an example:
scala> def factorial(n:Int):Int={
| if(n==1) return 1
| n*factorial(n-1)
| }
factorial: (n: Int)Int
scala> factorial(5)
The output will be:
Int = 120