Write Recursive Haskell Function Cannot Use Existing Functions Following Write Function Re Q37117239

Write arecursive Haskell function (you cannot use existing functions) todo the following:

Write a functionreachSum that takes an Int as the target sum, which will bepositive, and a list of positive Int values. You should return anInt (n) such that the sum of the first n elements is less than orequal to the target, but the sum of the first n+1 elements isgreater than the target. If the sum of the list overall is lessthan the target, return the number of elements in the list. Forexample:

reachSum 40 [12, 27, 13, 10] -> 2

reachSum 100 [12, 27,13, 10]

OR
OR

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.