Question: Consider a class MathUtils which has method that perform various mathematical functions using recursion. public class MathUtils { public static int factorial ( int n)
Consider a class MathUtils which has method that perform various mathematical functions using recursion.
public class MathUtils
{
public static int factorial ( int n)
{
//to be implemented }
public static int power ( int base, int exp)
{
// to be implemented}
public static void triple (int[] a)
{
//to be implemented}
}
The factorial method returns the factorial of the number given. Implement factorial using recursion.
The power method raises base to the power exp. Implement power using recursion.
The triple method triples every element in the given array. Implement triple using recursion, adding a helper method if necessary.
Step by Step Solution
3.52 Rating (165 Votes )
There are 3 Steps involved in it
Lets implement the methods in the MathUtils class using recursion Step 1 Implement factorial Method ... View full answer
Get step-by-step solutions from verified subject matter experts
