Question: In JAVA Code, Write a class that will contain: 1.) a recursive method that will calculate any base to any power 2.) call the recursive
In JAVA Code,
Write a class that will contain:
1.) a recursive method that will calculate any base to any power 2.) call the recursive method from main 3.) write the loop version of the method 4.) call the loop version from main 5.) check that both methods return the same answer 6.) **extra credit: measure the number of nanoseconds that each method takes, & report which version of the methods is faster. Use either System.currentTimeMillis() or System.nanoTime() to get the start and end time assigned to 2 long variables, then subtract, and that is your total time.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
