function Solve(MyArray() as integer,ArraySize as integer,Result as integer) as integer dim as integer Combinations = (ArraySize^ArraySize)*(4^(ArraySize-1)) dim as integer OpOp = (ArraySize * 2) - 1,ReturnValue for i as integer = 0 to Combinations - 1 dim temp as integer = i dim TextResult as string = string$(ArraySize-1,"("), NumResult as integer dim as integer ArrayNum,Number = 1 shl (temp mod ArraySize) NumResult = MyArray(temp mod ArraySize) Temp \= ArraySize TextResult &= str$(NumResult) for j as integer = 1 to OpOp-2 step 2 dim as integer OpNum = temp and 3 temp shr= 2 ArrayNum = Temp mod ArraySize if ((1 shl (Temp mod ArraySize)) and Number) then continue for, for Number or= 1 shl (Temp mod ArraySize) Temp \= ArraySize select case OpNum case 0: NumResult += MyArray(ArrayNum): TextResult &= "+" case 1: NumResult -= MyArray(ArrayNum): TextResult &= "-" case 2: NumResult *= MyArray(ArrayNum): TextResult &= "*" case 3: NumResult \= MyArray(ArrayNum): TextResult &= !"\\" end select TextResult &= str$(MyArray(ArrayNum)) & ")" next j if Result = NumResult then print TextResult & "=" & NumResult ReturnValue += 1 end if next i return ReturnValue end function dim as integer NumberArray(4-1) = {13, 2, 4, 5} dim as integer Result Result = Solve(NumberArray(),4,27) print print "Found " & Result & " Results." sleep