Quelltext JavaScript 1.2

//// This JavaScript 1.2 program finds all combinations of two to nine// digits and calculates each resulting sum.//// 2004-03-26 by Michael Pousen//// This program is free software; you can redistribute it and/or modify// it under the terms of the GNU General Public License as published by// the Free Software Foundation; either version 2 of the License, or// (at your option) any later version.//// This program is distributed in the hope that it will be useful,// but WITHOUT ANY WARRANTY; without even the implied warranty of// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the// GNU General Public License for more details.//

Quelltext Visual Basic .NET 7.1

'' Dieses Visual Basic .NET 7.1 Programm findet alle Kombinationen von zwei bis neun' Ziffern und berechnet deren jeweilige Summe.'' 2004-03-20 by Besserwisser' 2004-03-26 output directed to console by Michael Pousen'' This program is public domain software.' It is distributed in the hope that it will be useful,' but WITHOUT ANY WARRANTY; without even the implied warranty of' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.'

Quelltext Microsoft Excel 8

Attribute VB_Name = "XSums"'' This Microsoft Excel 8 macro finds all combinations of two to nine' digits and calculates each resulting sum.'' 2004-03-26 by Michael Pousen'' This program is free software; you can redistribute it and/or modify' it under the terms of the GNU General Public License as published by' the Free Software Foundation; either version 2 of the License, or' (at your option) any later version.'' This program is distributed in the hope that it will be useful,' but WITHOUT ANY WARRANTY; without even the implied warranty of' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the' GNU General Public License for more details.'

' recursive function to find all cobinations' depth = maximum search depth = amount of digits' level = current search depth' lower = lowest digit to add to the combination' found = found digits in boolean arraySub FindSums(ByVal depth As Integer, ByVal level As Integer, ByVal lower As Integer, ByVal found As Variant) Dim i As Integer Dim currCol As Integer If (level > depth) Then ' Loop over the array of the found digits and place them in the current row. currCol = 2 For i = 1 To 9 If found(i - 1) Then ActiveCell.Offset(currLine, currCol).Value = i currCol = currCol + 1 End If Next ' Calculate sum and set length. ActiveCell.Offset(currLine, 1).Value = Application.WorksheetFunction.sum(Range(Cells(currLine + 1, 3), Cells(currLine + 1, depth + 3))) ActiveCell.Offset(currLine, 0).Value = depth currLine = currLine + 1 Else ' Create all still possible combinations of digits. ' The lowest digit is defined by the one we had a level before, so we ' do not have duplicate tries here. ' The highest digits is defined by the amount of digits that follow ' until depth is reached. For i = lower To 9 - depth + level ' Mark digit as "in use" found(i - 1) = True ' until we add the next one to the combination. Call FindSums(depth, level + 1, i + 1, found) ' Clear flag afterwards. found(i - 1) = False Next End IfEnd Sub