В случае 5 чисел я бы просто перебрал его и попробовал все 32 возможные комбинации.
Вот несколько возможных псевдокодов для этой задачи:
input = Array of 5 random integers (starting with index 0)
onoff = new Array of 5 integers (starting with index 0), initialized to 0
loop
// Create all possible combinations of 0 and 1 in onoff Array
// Hint: This is the same as counting up a binary number and looking at the bits.
onoff[0] = onoff[0]+1
for i=0 to 3
if onoff[i] > 1
onoff[i] = 0
onoff[i+1] = onoff[i+1] + 1
if onoff[4] > 1
break loop
// Create sum for given combination
sum = 0
for i=0 to 4
sum = sum + onoff[i]*input[i]
if sum = 15
output "Found value set"
for i=0 to 4
if onoff[i] = 1
output " "+input[i]
Перевод на VBеще домашнее задание: -)