18
$\begingroup$

My friend and I are each trying to form the integers from $0$ to $100$ using the numbers $2, 3, 8, 9$. We are only allowed to use the five basic operations: addition, subtraction, multiplication, division, exponentiation, as well as parentheses. No concatenation is allowed. Each expression must use all four of $2,3,8,9$ exactly once.

After we work on the problem for a while, I find 89 different integers, while my friend only finds 88 different integers. We compare our work, and we realize that I found one extra number beyond the ones my friend found. The reason my friend missed an integer is because my friend simplified their calculations by discarding any expression in which an intermediate result is not an integer. With this restriction, it was impossible for my friend to form the final integer.

Which extra integer did I find?


Using all of the numbers $2,3, 8, 9$ exactly once and any of the operations $+, -, *, /, \wedge$, which integer between 0 and 100 can only be formed by an expression with a non-integer intermediate value?

$\endgroup$
7
  • 4
    $\begingroup$ This is an interesting take on the formation-of-numbers genre - on first glance, at least, it seems far more interesting and fresh than merely 'make lots of numbers out of these other numbers' :) $\endgroup$
    – Stiv
    Oct 6, 2022 at 10:32
  • $\begingroup$ When you say it was impossible , is there a Proof of this ? Or just Empirical guess work ? $\endgroup$
    – Prem
    Oct 6, 2022 at 11:11
  • 3
    $\begingroup$ @Prem I've verified this impossibility with a computer program. $\endgroup$
    – isaacg
    Oct 6, 2022 at 11:13
  • $\begingroup$ oh great , +1 then !! $\endgroup$
    – Prem
    Oct 6, 2022 at 11:14
  • 2
    $\begingroup$ Do expressions need to contain all 4 of the numbers? $\endgroup$
    – xnor
    Oct 6, 2022 at 11:15

2 Answers 2

11
$\begingroup$

Non-programming solution to find the number:

The only thingy making non-integers here is division. Non-integer intermediate result of $2^3 \cdot$$9 \over8$ doesn't require non-integer results by simple rearrangement, likewise for $3^2 \cdot$$8 \over9$.
$3$ and $9$ are divisible by just $3; 2$ and $8$ are by just $2$. Therefore, $2\cdot\left(x+\frac{y}{8}\right)$ cannot end up as integer, same for $3\cdot\left(x+\frac{y}{9}\right)$.

As noticed by Kris in comments, we also have $8^{3 \over9}$ to eliminate, varying places for the 2. Those variations ending up as integer get all eliminated by equality $8^{3 \over9}$ = 2 = (8+3-9).

So, the solution is either $8\cdot\left(x+\frac{y}{2}\right)$ or $9\cdot\left(x+\frac{y}{3}\right)$. The latter is trivially rearranged as $9x+3y$ with the same result. So, we need to get either

$8\times(3+9/2) = 60$ or
$8\times(9+3/2) = 84$

The former is also $(9-3) \times (8+2) = 60$, eliminating it as a possibility.

The latter is trivially $9^2+3 = 84$, but proving that it is impossible to make by using all numbers requires exhaustive listing of all combinations - but I am not going to do that by hand, there are too many. Here I am just going to rely on correctness of code by OP and other answer.

$\endgroup$
3
  • 1
    $\begingroup$ Very nice, I think this is as far as you can go without computer help. $\endgroup$
    – quarague
    Oct 7, 2022 at 9:19
  • 1
    $\begingroup$ This was the solution I was hoping for - and I'm totally ok with relying on the existence of a solution after eliminating all other possible integers $\endgroup$
    – isaacg
    Oct 7, 2022 at 15:28
  • 2
    $\begingroup$ Another path to eliminate is forms like 8^(2*3/9). $\endgroup$ Jan 8 at 7:34
13
$\begingroup$

The result is:

$84 = 8 \cdot (9 + \frac{3}{2})$

There is no other way to form the number without getting a non-integer value during one of the steps.

Here is the Python code I used to generate ways to form each number without any intermediate non-integer results:

nums = [2, 3, 8, 9]

formed = [{} for i in range(16)]
formed[1][2] = "2"
formed[2][3] = "3"
formed[4][8] = "8"
formed[8][9] = "9"

def make_exp(left, right, op):
    return "("+left+")"+op+"("+right+")"

for setbits in range(2, 5):
    for i in range(16):
        if i.bit_count() != setbits: continue
        for j in range(16):
            if i & j == j != i:
                for x in formed[i^j]:
                    for y in formed[j]:
                        if x+y <= 100:
                            formed[i][x+y] = make_exp(formed[i^j][x], formed[j][y], "+")
                        if 0 <= x-y:
                            formed[i][x-y] = make_exp(formed[i^j][x], formed[j][y], "-")
                        if x*y <= 100:
                            formed[i][x*y] = make_exp(formed[i^j][x], formed[j][y], "*")
                        if y and x%y == 0:
                            formed[i][x//y] = make_exp(formed[i^j][x], formed[j][y], "/")
                        if x**y <= 100:
                            formed[i][x**y] = make_exp(formed[i^j][x], formed[j][y], "^")

for x in sorted([each for each in formed[15]]):
    print(x, " = ", formed[15][x])

Slightly tweaking it to allow non-integer results in the middle and then comparing the outputs does the trick.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.