Extra: Implement fib in 5 lines or fewer. Your answer must be efficient.
1 2 3 4 5 6 7
publicstaticintfib2(int n, int k, int f0, int f1) { if (n == k) { return f0; } else { return fib2(n, k + 1, f1, f0 + f1); } }
Q2
Implement square and squareMutative which are static methods that both take in an IntList L and return an IntList with its integer values all squared. square does this non-mutatively with recursion by creating new IntLists while squareMutative uses a recursive approach to change the instance variables of the input IntList L.