given an array and a number x find the set of numbers whose sum is less than x but closest to it.
Answers
Answered by
0
if the array is 1,4,7.... and the number is 100 we have to find sum of 1,4,7... just short of 100. For an A.P. sum is 0.5*n*(2*a+(n-1)*d). With a equals 1 and d=3 putting the equation = 100 gives n a little above 8 so n=8 and sum of series with 8 terms 92.
Similar questions