Question: How to stop adding element of sets after reaching certain value and catch the element

Dear all,

Does anyone know how to do this case?

For example, given a sets A={20,15,10,30,46,78}. Then I put the upper bound = 50
I want to add the elements and stop adding before reaching or exceed the upperbound. So, what I want to achieve is

B={20,15,10} since 20+15+10 +30 = 75. Stop in 4th element.

Thank you


Please Wait...