Write a recursive method to compute the power of x n for non-negative n.
What will be an ideal response?
```
public static int power(int x, int n)
{
if(n < 0)
{
System.out.println("Illegal argument to power");
System.exit(0);
}
if(n > 0)
return (power(x, n-1) * x);
else
return(1); //base case
}
```
You might also like to view...
When working with tables, the Delete button on the Layout tab allows you to delete all of the following EXCEPT:
A) cell contents only. B) a cell and its contents. C) an entire row. D) an entire table.
Policies are broad and provide the foundation for development of standards, baselines, guidelines, and procedures
Indicate whether the statement is true or false.
Which of the following is a componentused by a cloud user in a cloud computing environment?
a. A storage device b. A web server c.An operating system d. A smartphone
Make a judgment about why emergent requirements present a challenge to conventional software engineering approaches.
What will be an ideal response?