Question: Write a method called checkArray that: - takes as argument an array of integers, arr, and - returns true of false if the array has
Write a method called checkArray that:
- takes as argument an array of integers, arr, and
- returns true of false if the array has the property that, starting from the 3rd element to the end, every element equals the sum of the previous 2.
For example if {0,1,1,2,3,5,8,13} has this property: the 3rd element is 1 and it equals the sum of the previous two: 0+1. Next 2 = 1+1 and so on up to 13 = 5+8.
The array {0,1,1,3,4,7,11} does not have the property because 3 does not equal 1+1.
Please comment through your code. Thanks
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
