#include $iRequiredSum = 27 Global $aArray = [1,2,3,4,5,6,7,8,9, _ 1,2,3,4,5,6,7,8,9, _ 1,2,3,4,5,6,7,8,9, _ 1,2,3,4,5,6,7,8,9, _ 1,2,3,4,5,6,7,8,9, _ 1,2,3,4,5,6,7,8,9, _ 1,2,3,4,5,6,7,8,9, _ 1,2,3,4,5,6,7,8,9, _ 1,2,3,4,5,6,7,8,9] ; Increase the number of factors on each pass For $iSet = 1 To UBound($aArray) ; Determine the possible combinations $aCombinations = _ArrayCombinations($aArray, $iSet, "+") ; For each combination For $j = 1 To $aCombinations[0] ; Break into factors $aFactors = StringSplit($aCombinations[$j], "+") ; Sum factors $iSum = 0 For $k = 1 To $aFactors[0] $iSum += $aFactors[$k] ; Are we over the required sum? If $iSum > $iRequiredSum Then ; No point in adding further factors <<<<<<< ExitLoop EndIf Next ; If sum is required value If $iSum = $iRequiredSum Then ; Write first combination found for this number of factors <<<<<<<<< ConsoleWrite("For " & $iSet & " factors" & @CRLF & $aCombinations[$j] & " = " & $iRequiredSum & @CRLF) ; Move immediately to increase the number of factors <<<<<<<<< ExitLoop EndIf Next Next