47

The sequence of numbers $1\ 2\ 3\ 4\ 5\ 6\ 7\ 8\ 9$ has the property that you can insert mathematical operators in between the numbers from $1$ to $9$ and make the expression evaluate to 100. For example:

$$1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 \times 9 = 100$$

There are possibly hundreds of solutions to this problem, involving different varieties of operators. What is the expression with the fewest number of operators inserted (out of the set $+, -, \times, \div$ and maybe $\sqrt{}$ and $!$) that evaluates to 100?

Rand al'Thor
  • 116,845
  • 28
  • 322
  • 627
  • What is the assumption if I do not insert a symbol? Does 1 2 3 just become the number 123? – trh178 Apr 13 '15 at 19:35
  • Yes, exactly. Similarly, if you insert no symbols at all, then the number is just 123456789. –  Apr 13 '15 at 19:35
  • 5
    Can I insert a symbol between = and 100? – Ben Frankel Apr 13 '15 at 19:45
  • If it can beat the current solution, try. But generally, you can only insert symbols on the left side. (Also, no modifying the equals sign to do "not equals". That's a standard loophole and it doesn't apply.) –  Apr 13 '15 at 19:49
  • Can I add digits in between the integers? – Ben Frankel Apr 13 '15 at 20:32
  • 1
    Well anyways if I can, I have a cute solution with 4 added symbols: $1-2\times3345+6789 = 100$. – Ben Frankel Apr 13 '15 at 20:58
  • 11
    @JoeZ. You should define the question such that you don't need to make ex post facto judgements on what is or isn't allowed. You failed to specify specifically which "mathematical symbols" are allowed and their meaning. Numbers are symbols, and they are used in mathematics. Taking it a step farther, I could invent a new operator with its own symbol (as is often done in mathematics) and define it to always evaluate to 100. Stick it anywhere on the left and voila: 100 = 100, one added symbol. – bcrist Apr 14 '15 at 01:10
  • 4
    @JoeZ. I wasn't complaining or implying that my hypothetical solution should be considered a valid solution to the puzzle, but trying to point out that if you explicitly listed the specific operators and their acceptable meanings (some operators have different or multiple meanings in different areas of mathematics) you would not need to contend with a plethora of "clever" solutions utilizing lateral thinking. – bcrist Apr 14 '15 at 01:47
  • 4
    @JoeZ. I believe my first comment was and still is quite constructive: it gives specific advice for how to describe the puzzle less ambiguously. Namely, by listing each symbol/operator which is acceptable and what meaning it has. What irritates me is when people misinterpret constructive criticism and cry foul instead. – bcrist Apr 14 '15 at 02:07
  • 3
    @bcrist I apologize. I got antsy about this because I've been accused of moving the goalposts in much the same way at PCG.SE (the code golf site) more than once, and it pattern-matches to people complaining about "chameleon questions" where people do indeed believe their loophole-abusing solutions should be considered valid even if they ruin the challenge, almost as a penalty to the question-asker for not making the question clear enough in the first place. Looking back at my first reply to you, some of my negativity was pretty uncalled for, so I've just deleted my comments. –  Apr 14 '15 at 05:50
  • If it wasn't for your last edit 123456789 != 100 might have been a short good programmer-ish solution :) – dmg Apr 14 '15 at 12:29
  • 123456789 factorial is nowhere close to 100, though. –  Apr 14 '15 at 16:09
  • @bcrist That being said, I think I would have been more likely to have seen your comment as constructive if there weren't all that framing about "You should define the..." etc., which triggered the pattern-matching I mentioned regarding the people at PCG.SE. I'm always happy to better define my problems, but I'm more likely to accept direct suggestions for that reason. –  Apr 14 '15 at 16:33
  • 1
    @JoeZ. I'll admit; starting my first two sentences with "You should" and "You failed" probably set an overly negative tone. – bcrist Apr 15 '15 at 01:38
  • FWIW, here are all solutions using only +, -, / and *. https://gist.github.com/schleppy/6e121d7f5e55b71797dd – sberry Apr 16 '15 at 02:07
  • I gotta say, it's a fine enough puzzle but I feel that it's getting way too much attention given that the accepted answer is easily found with a Google search. – Engineer Toast Apr 16 '15 at 12:26
  • @EngineerToast I know. This is yet another chestnut, it seems. –  Apr 16 '15 at 15:13
  • 1
    As the question is worded "a sequence of numbers", the only answer is 8. Since the question was not worded as "a sequence of digits", the digits of numbers have to be taken as is and cannot be clumped into NEW numbers. (That is, 1 and 2 are exactly that. They are not together, the number 12). – Thomas Eding Apr 16 '15 at 16:26
  • @ThomasEding I specified in a comment above that numbers without operators between them would be strung together automatically, but if you want I'll edit that into the question to be super clear. –  Apr 16 '15 at 16:27

10 Answers10

93

Note: This answer only applies prior to the edit that clarifies that the expression on the left must evaluate to 100, rather than simply the equation being true.

If you allow exponents, you can get away with just two:

$ 1^{ 23456789 } = 10^0 $

Ian MacDonald
  • 12,806
  • 1
  • 33
  • 63
  • 2
    Well, you're not supposed to be able to insert anything between the digits of 100, but +1 for creativity. –  Apr 14 '15 at 03:17
  • I didn't mean to loophole, I guess I just misinterpreted your comment to Ben (But generally, you can only insert symbols on the left side.) – Ian MacDonald Apr 14 '15 at 11:38
  • Even if you were allowed to insert symbols on both side, this would still require 3 if you want to be proper. Since 00 is nonsense, I see the full equation as 1^23456789=1^0^0. – Engineer Toast Apr 14 '15 at 12:02
  • 1
    @EngineerToast 00 is not nonsense, though. Surely you understand it (and therefore it makes sense). – Ian MacDonald Apr 14 '15 at 12:17
  • I think even if it counts as 3 using 0^0, it's still better since it's 3 using 1 operation instead of 3 using 2 operations. – rmoore Apr 14 '15 at 13:39
  • 8
    @EngineerToast It would be 2 operations since you could write 1^23456789=10^0 – pacoverflow Apr 14 '15 at 16:01
  • 1
    Also, $0^0$ is undefined. –  Apr 14 '15 at 16:28
  • 1
    @pacoverflow +1 Good optimization. – Engineer Toast Apr 14 '15 at 22:06
  • @JoeZ. 0^0=1for many - but admittedly not all - applications. It's an old argument. pacoverflow's solution is better, anyway. – Engineer Toast Apr 14 '15 at 22:10
  • When defining exponents as $x^y$ is the multiplicative identity in the field multiplied by $x$ $y$ times, then you can clearly see that $0^0 = 1$. Dunno why we're discussing it, though... :( (note that negative numbers are interpreted as division properly in this definition) – Ian MacDonald Apr 14 '15 at 23:03
67

I believe that this is the smallest:

$123 - 45 - 67 + 89 = 100$

JMP
  • 35,612
  • 7
  • 78
  • 151
Andrew Smith
  • 1,694
  • 12
  • 9
29

Best I can do so far is tie the smallest (3 operators):

1234%567%8^9 = 100
which Wolfram Alpha interprets as:
$(1234\bmod567)\bmod8^9 = 100$
$(100)\bmod8^9 = 100$

For those who are unfamiliar, % is the modulo operator. Throw the equation in wolfram alpha.

EDIT: Started on finding this solution before the operator limit was imposed. Not valid under the rules of the current question.

Mwr247
  • 525
  • 3
  • 6
  • How exactly does that work? I can't figure out which % applies first. –  Apr 14 '15 at 18:22
  • Please add parenthesis to your answer, they won't be counted as operators (I guess) – leoll2 Apr 14 '15 at 18:24
  • 4
    Modulus works at the same level as multiplication/division in the order of operations. As such, no parenthesis are needed. The exponent is resolved first, then we work left to right with the modulus signs. – Mwr247 Apr 14 '15 at 18:27
  • I agree that no parentheses are needed; I added them in to help people read it, though. – Ian MacDonald Apr 14 '15 at 18:27
  • @IanMacDonald Thanks for that. Still, I'm curious who's left me with a -1 for a valid answer that wasn't simply googled... – Mwr247 Apr 14 '15 at 18:30
  • @Mwr247: It wasn't me, but technically this answer isn't valid. It uses operators outside of the set specified explicitly by the question. – Ian MacDonald Apr 14 '15 at 18:33
  • @IanMacDonald Whoops! When I started working on that solution, it was before the edit that added the restricted operator set. Didn't see the change until now. My bad =( – Mwr247 Apr 14 '15 at 18:34
  • 1
    @Mwr247: I know what you mean. My answer was posted before the edit, too. People still keep upvoting it, though. -_- – Ian MacDonald Apr 14 '15 at 18:36
  • 1
    @IanMacDonald To be fair, yours was particularly clever hehe... Anyways, unless the rules change to allow modulo (which it totally should, given how ubiquitous it is), I've added a note to my answer indicating that it's not technically valid. Thanks again everyone =) – Mwr247 Apr 14 '15 at 18:40
  • Sorry, but for the Modulo operation you have to specify the order by putting parantheses around them. (78 mod 10) mod 7 = 8 mod 7 = 1, but 78 mod (10 mod 7) = 78 mod 3 = 0. It is the same level as division, where you also have to put paratheses: (78 / 10) / 7 = 7.8 / 7 = 1.1143... approx , while 78 / (10/7) = 78 / 1.4286... = 54.6 – jjdb Apr 16 '15 at 11:11
  • 1
    @jjdb Parentheses are used to override the normal order of operations, and themselves have a place in that order (albeit at the top). When not specified, the implicit order is to solve from left to right. Parentheses are therefore not required, but rather, recommended for clarity. The case you gave as an example, without parenthesis, would evaluate as: 78 / 10 / 7 = 1.1143... approx. – Mwr247 Apr 16 '15 at 13:37
17

Addendum too long for a comment

I can confirm there is no better solution than Andrew Smith's if we use the operators +-*/.^ There is only one solution using 3 operators. There are two using 4:

123 +45 - 67 + 8 - 9
123 + 4- 5 + 67 - 89

There are 215 possibilities total and the number of solutions for the number of operators breaks down as follows:

Operators   Solutions   
0           0
1           0
2           0
3           1
4           2
5           9
6           57
7           104
8           42

We could throw in some more operators though I doubt they would help. I didn't try parentheses, floors, mod, sqrt, etc. If anyone wants a go, though, here's some (unoptimized) VBA that will brute force the basic operators in Excel:

Sub doTheMath()
Const op As String = " +-*/.^"
Dim s As String
Dim a, b, c, d, e, f, g, h
Dim i, j
Dim v

'Loop all possibilities
i = 2
j = 1
For a = 1 To Len(op):    For b = 1 To Len(op):    For c = 1 To Len(op):    For d = 1 To Len(op)
For e = 1 To Len(op):    For f = 1 To Len(op):    For g = 1 To Len(op):    For h = 1 To Len(op)
    s = 1 & Mid(op, a, 1) & 2 & Mid(op, b, 1) & 3 & Mid(op, c, 1) & 4 & Mid(op, d, 1) & 5 & _
        Mid(op, e, 1) & 6 & Mid(op, f, 1) & 7 & Mid(op, g, 1) & 8 & Mid(op, h, 1) & 9
    v = Application.Evaluate(Replace(s, " ", ""))
    If CStr(v) = CStr(100) Then
        Cells(i, 1).Value = s
        Cells(i, 2).Value = v
        i = i + 1
    End If
    j = j + 1
    If j > 1000000 Then
        ThisWorkbook.Save
        j = 1
    End If
Next:    Next:    Next:    Next:    Next:    Next:    Next:    Next

End Sub

Engineer Toast
  • 17,506
  • 1
  • 49
  • 152
  • @stuartstevenson I can confirm there is no better solution than Andrew Smith's if we use the operators +-*/.^ There is only one solution using 3 operators. The solution you posted is the one solution using 3 operators that was posted by Andrew Smith. – Engineer Toast Jan 08 '20 at 13:16
3

Disclaimer: I do not own any of the answers. This is only an arrangement of all the answers. Credits to Andrew Smith, Ismael Miguel, Mwr247, Ian MacDonald and Engineer Toast.


2 operators:

$$1^{23456789}= 10^0$$ (by Ian Macdonald)

3 operators:

$$123−45−67+89=100$$ (by Andrew Smith)

$$1234\%\,567\%\,8^9 = 100$$ (by Mwr247)

4 operators:

$$123 +45 - 67 + 8 - 9$$ (by Engineer Toast)

$$123 + 4- 5 + 67 - 89$$ (by Engineer Toast)

7 operators:

$$-(12+34-56)\times (-7+8+9)=100$$ (by Ismael Miguel)


So far, answerers need to figure out a solution with 2 operators only to update the record.

  • Hope you like the edit! If not, let me know as soon as you can, or just implement a rollback. – Mr Pie Apr 12 '19 at 00:21
  • Consider editing this to make it a community wiki. I do not own any of the answers. This is only an arrangement of all the answers. – Engineer Toast Jul 16 '21 at 14:14
2

I'm adding this because I like it and I remember figuring it out as a child.

$((1+2) \times 3 + 4 + 5) \times 6 - 7 + 8 - 9 = 100.$

It's nice because the order of operations work left to right and I guess is technically the shortest without the concatenation or modulo functions.

1

This is my 2nd attempt.

This time I'm using 7 operations.

I couldn't find any shorter than this, for now.

-(12+34-56)*(-7+8+9)

I've tried and tried and tried.

This simply multiplies 10 by 10.

Nothing fancy, sadly too long, nothing that can't be done easily...

But well, it solves the case!

Ismael Miguel
  • 447
  • 3
  • 12
0

I know that technically I do not have a shorter solution, but I applied the modulo operator and found an answer!

123456789 % 123456689 = 100

and so on. The program I used:

#include <iostream>

int
main()
{
  for (int i = 100; i < 999999999; i++)
    {
      if (123456789 % i == 100)
        {
          std::cout << i << std::endl;
        }
    }
}
Theolodis
  • 125
  • 4
0

Here are some answers I found.

$$\begin{align}100 &= 1 \times (- 2) + 3 \times 4 + 5 + 6 +7 + 8 \times 9 \\ &= 12 - 3 + 4 \times 5 + 6 + 7 \times 8 + 9 \\ &= 1 + 2 + 3 - 4 + 5 + 6 + 78 + 9 \\ &= 12 + 34 - 5 + 6 \times 7 + 8 + 9 \\ &= 1 \times 2 + 3 \times 4 + 5 - 6 + 78 + 9 \\ &= 1 \times 2 \times 3\times 4 + 5 + 6 -7 + 8 \times 9 \\ &= 1 \times 2 + 34 + 56 + 7 - 8 + 9.\end{align}$$

The trick is

including negatives from $-2$ to $-8$. There appears to be a solution when each of these terms are included in each sum to equal $100$. Strange, ain't it?

Just wanted to point out that trick.

Mr Pie
  • 6,682
  • 1
  • 25
  • 88
-5

I'm not sure this is what you're looking for, but 123456789=/=100

This answer adds two symbols, "=" and "/".

DiscOH
  • 436
  • 2
  • 9
  • 2
    You can't do that, though. The symbol =/= doesn't mean anything, and even if you were trying to change it to $\neq$, that's specifically disallowed. –  Apr 14 '15 at 00:20
  • Would you be happier with "123456789 != 100"? ! meaning "not" is listed in wikipedia's big list of math symbols

    http://en.wikipedia.org/wiki/List_of_mathematical_symbols

    – DiscOH Apr 14 '15 at 01:03
  • 10
    Well, the problem is with the word "equation". Sure you've made the statement true, but it's no longer an equation. –  Apr 14 '15 at 01:37
  • @JoeZ. An equation is an equality with at least one variable. What you mean is an equality. – user26486 Apr 14 '15 at 23:23
  • Well, in any case I've edited the question statement again and that removes any ambiguity with regards to my choice of word when it comes to "equation". –  Apr 15 '15 at 00:04