Question: Write a method largerProduct() that is passed an array, arr, of integers, using the header below. The method should use recursion to multiply together

Write a method largerProduct() that is passed an array, arr, of integers, 

Write a method largerProduct() that is passed an array, arr, of integers, using the header below. The method should use recursion to multiply together some of the items in the array: if an element is more than the position where it is stored in the array, then it should be included in the product; but if the element is less than or equal to the position where it is stored, then it should not be included in the product. (You may write a helper method if you need to.) For example, if arr = { 0, 2, -1, 4, 1, 5, 3, 9, 4}, then the method should return 2*4*9=72, because (for example): item 2 is stored at position 1 and 2 > 1, so 2 is included in the product; and so is item 4 at pos 3; and item 9 at pos 7. item -1 is stored at position 2 and -1

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!