Given an array of integers of at least length > 15, allow the first 15 integers to pass without inspection. Starting at the 16th integer: Return the first integer in the list that is not a sum of any two integers found in the PREVIOUS 15 integers in the list. If all integers in the array after the first 15 pass this test, return 0. The array only includes positive integers, but is not guaranteed to be strictly increasing or decreasing. The array can include duplicates, but will not include 0.
Input:
[55, 59, 3, 25, 37, 2, 38, 58, 6, 53, 55, 84, 45, 89, 90, 58, 31, 8, 122, 59, 100, 116, 39, 97, 123, 218, 130]
// [ 55, 59, 3, 25, 37, 2, 38, 58, 6, 53, 55, 84, 45, 89, 90 ]
// Remember [114, 58, 80... 62 .... length = 210]
Elaborate:
Index 0-14: Passed without any code as part of problem statement
Index 15: 58 is the sum of 3 (idx 2) and 55 (idx 0) (Go on)…
Index 16: 31 is the sum of 6 (idx 8) and 25 (idx 3) (Go on)…
Index 17: 8 is the sum of 6 (idx 8) and 2 (idx 5) (Go on)…
Please note that the numbers considered are always the previous 15 numbers in the list, and not necessarily the first 15 numbers.
Is any number NOT a sum of some other two numbers in the prior 15 numbers?