Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Question 1:
- In the preferred Scala style it almost always possible to avoid using explicit return statements. All expressions return a value so the first function could be written this:
- def nthFibonacci(n : Int): Int ={
- if (n == 1 || n == 2) n
- else nthFibonacci(n-1) + nthFibonacci(n-2)
- }
Advertisement
Add Comment
Please, Sign In to add comment