Microsoft Interview Question

optimized sum of array elements divisible by x