OFFSET
1,1
COMMENTS
a(1)=160 is the smallest number which can't be described by such expressions.
159 has 6 ways to reach it: 159 = 123-45-6+78+9 = 123+4+56-7-8-9 = 1+234+5+6-78-9 = 1+23+45-6+7+89 = 123-4-56+7+89 = 1-2+3-4+5+67+89.
There are 3^8=6561 ways to form expressions of that kind, including duplicates and negative numbers. - R. J. Mathar, Dec 07 2009
PROG
(Excel) VBA Program:
Sub Test() Dim Solutions(1 To 1000), result As Single Dim temp As Long, x(1 To 17) As String, op Dim i As Long, j As Long, out As String, num As Long op = Array("+", "-", "") For i = 1 To 9 x(2 * i - 1) = i Next For i = 0 To 3 ^ 8 - 1 temp = i For j = 1 To 8 x(2 * j) = op(temp Mod 3) temp = temp \ 3 Next out = Join(x, "") result = Evaluate(out) If result > 0 Then If result < 1001 Then Solutions(result) = Solutions(result) + 1 End If End If Next For i = 1 To 1000 If Solutions(i) = 0 Then Debug.Print i; Next End Sub
CROSSREFS
KEYWORD
nonn,easy,base
AUTHOR
Zhining Yang, Dec 05 2009
EXTENSIONS
Definition rephrased, terms beyond 300 added by R. J. Mathar, Dec 07 2009
STATUS
approved