Recursion Question
5. In the following question, you will be asked to program the following using recursion. If you have an iterative
solution, you may use it, but the most you can get for the question will be half credit. (5) points)
Consider the following mathematical function h which operates on integers.
(1,
if n < 2
h(n) = n(n-1) +n if n > 2 and n is even
han -2) +2*n if n > 2 and n is odd
In Java, use recursion to write a method h which takes as input an int n and returns h (n).
public static int h(int n) {