I have a list of integers. The first n
members of the lists will, when added to each other, will result in the n + 1
st member of the list. . I would like to replace each list with the accumulated sum when a match occurs; if there is more than one match (e.g. lis5
), replace the list with the numerically largest match.
lis1 = {8,2,3,9,22} res1 = 22
lis2 = {9,11,21,3,44,12,3} res2 = 44
lis3 = {3,8,2,1,12,26} res3 = 26
lis4 = {8,4,6,2,9,11,40,3} res4 = 40
lis5 = {3,7,10,2,14,36,4} res5 = 36 (not 10)
Testing recursively the accumulated sum against each succeeding element until a match is found. Thanks for any ideas...