# How to get 32 by using +1 , +1 , ×3 , ×3 , ÷2 , ÷2, ^2, ^2?

How to get 32 by using +1,+1,×3,×3,÷2,÷2,^2,^2?
(The last two operators are 'squaring'.)

• would you please clarify what number to start from? I assume it is zero, as do the responders (so far), but the question as it stands does not contain that restriction - it doesn't even mention use of a calculator device, which commonly start from implicit zero – Leif Willerts Apr 23 '20 at 20:04
• Why not just +1+1... = 32? – S.S. Anne Apr 23 '20 at 20:40
• @S.S.Anne I think we're supposed to use exactly two of each, otherwise the repetition in the listing would be rather redundant. – Christian Gibbons Apr 23 '20 at 20:41
• I hope people make more of these puzzles so I can make more diagrams (wink wink). – Galen Apr 24 '20 at 0:00
• @EricDuminil well, another thing dictated by the calculator setup - which the question apparently is meant to imply - are strictly left-associative parentheses, not arbitrary ones. – Leif Willerts Apr 25 '20 at 23:54

I like Glorfindel's answer as it takes you through an example solution, and I recommend his answer. Just to show some underlying beauty and complexity of this puzzle, I created a diagram (directed multigraph) that shows all possible results (that yield integers) of permuting these operations. You'll have to open the image in another tab and magnify to follow it in detail. I hope you enjoy.

Note that the green nodes are those where at least one sequence of the operations terminates there.

# Starting at one:

Since there might be some interest in this case, here's a similar map.

It is not actually possible to get from 1 to 32 using exactly these 8 operations.

# Bonus Information

I checked every graph that starts at 0 up through 32, and confirmed that none of the other graphs terminate at 32. What's more, the answer given by Glorfindel is the only solution. This puzzle makes me happy.

• Nice! If I'm reading the graph correctly, it looks like the solution is unique. – Glorfindel Apr 23 '20 at 20:03
• @Glorfindel That's my understanding as well, assuming we use each of the eight given operations exactly once. – Galen Apr 23 '20 at 20:04
• @Galen: Nice diagrams. Graphviz can export to PNG directly, BTW. – Eric Duminil Apr 25 '20 at 11:55
• @Galen Graphs like these tend to make me drool uncontrollably, they are so ... soothing. I love these and tend to analyze them and follow the paths for no good reason whatsoever. Tremendous work! For some reason they reminded me of graphs representing the Collatz conjecture which I also liked. One thing that bothered me however is that the second graph (exported in JPG format) has visible artifacts, I wish it was a PNG image like the first one. – Tomalla Apr 26 '20 at 10:15
• I really appreciate all the constructive feedback and critical thinking in the comments of this answer. It is really cool to see that I made something that gets people thinking, which is what puzzles are about after all :) – Galen Apr 26 '20 at 15:36

Assuming you start with 0 (like on a calculator), this should work:

$$0 \times 3 = 0$$ $$0 + 1 = 1$$ $$1 \times 3 = 3$$ $$3 + 1 = 4$$ $$4^2 = 16$$ $$16 \div 2 = 8$$ $$8^2 = 64$$ $$64 \div 2 = 32$$

• Nice answer---I seem to have lost my ability to solve these things as I get older.....I get lost in the endlessly bifurcating trees. But what bothers me about some of these puzzles is that the zero (no matter how you arrive to it) can act as a way to "throw away" subsequent operations, no? For instance, you hucked out the x3 here. You could just as easily have thrown out any of the multiplications, divisions, and exponents. Nothing wrong with that at all, it's all part of the rules. But it seems less ....... interesting to me to allow it somehow. I wonder how a rule might limit that? – tgm1024--Monica was mistreated Apr 24 '20 at 1:13
• A possible rule would be to start with $x$ and forbid 0 as an intermediate result? – Glorfindel Apr 24 '20 at 15:50
• @Glorfindel Good one. Perhaps another could be that no two adjacent numbers in the calculation sequence can be equal, thus operations must always change the number. In some ways that is limiting, but it could apply to any collection of operations. – Galen Apr 24 '20 at 16:08
• another (more restrictive) rule would be to require each intermediate result to be distinct. – Jasen Apr 26 '20 at 10:53

I don't know how I got to this question from Stack Overflow... But here is the solution and the Python code for checking every combination:

((((((((0*3)+1)*3)+1)**2)/2.0)**2)/2.0)

lis = ['+1', '+1', '*3', '*3', '/2.0', '/2.0', '**2', '**2']
result = set()
def sol(lis, current, res, result):

if not lis and res == 32:
return

for i in range(len(lis)):
c = f"({current}{lis[i]})"
sol(lis[:i] + lis[i+1:], c, eval("res"+lis[i]), result)
sol(lis, 0, 0, result)
print(result)
$$$$
`
• Check out my answer to this question! You can see all the combinations that produce integers. – Galen Apr 24 '20 at 6:24
• You got here via the Hot Network Questions list, like many. Welcome! – Glorfindel Apr 24 '20 at 7:05
• @Galen the code style I mention ?? – snr Apr 24 '20 at 19:08
• @Frank Nice recursive definition! I'm a fan of recursion. – Galen Apr 26 '20 at 3:19

I noticed that there was a lot of emphasis around powers of 2, and that gave me an idea:

I started from the solution and brute-forced my way backwards. This puzzle can be rephrased as something like: Starting at 32, use these operators sequentially to get to 0: $$-1, -1, \div 3, \div 3, \times 2, \times 2, \sqrt(n), \sqrt(n)$$

Notably:

This set of inverse operations has a smaller search space because dividing by 3 and taking the square root are much more restrictive in their use.

My work:

$$32 \times 2 = 64$$ $$\sqrt(64) = 8$$ $$8 \times 2 = 16$$ $$\sqrt(16)= 4$$ $$4-1 = 3$$ $$3 \div 3 = 1$$ $$1-1 = 0$$ $$0 \div 3 = 0$$ Then all you have to do is re-invert the operations (and reverse their order) to get the answer of $$\times 3, +1, \times 3, +1, (n)^2, \div 2, (n)^2, \div 2$$

• Welcome to Puzzling! This is actually the method I used (at least to get to 4). – Glorfindel Apr 24 '20 at 15:49

This solution reduces the problem to a simpler one using each operation's effect on prime factorization.

We begin with $$0+1=1=2^03^0$$. Each step is represented by the form: $$2^n3^m$$.
We have the following operations:

$$(*3)$$ yields $$2^n3^{m+1}$$

$$(/2)$$ yields $$2^{n-1}3^m$$

$$(\hat{}2)$$ yields $$2^{2n}3^{2m}$$

and $$(+1)$$ "randomly" shuffles/introduces new exponents. Our desired number is $$2^5=32$$.
The only reasonable first step is to increase the exponents from zero, so we can apply: $$2^03^0*3=2^03^1$$ We then use our only chance to get rid of the $$3$$ factor entirely: $$2^03^1+1=2^23^0$$ We must get from $$2^2\rightarrow2^5$$, so let's reduce the problem to solving $$2\rightarrow5$$ using the remaining four operations (on the exponent): $$(-1), (-1), (*2), (*2)$$. Let's start backwards from $$5$$:

The last operation must have been $$6-1=5$$ (because $$2.5*2$$ is unreachable),

Next must have been $$3*2=6$$, (cannot be $$7-1=6$$, because $$2*2*2\neq7$$),

$$3$$ is odd, so we came from $$4-1=3$$, and finally $$2*2=4$$.

Converting everything back, we have performed the following:
$$(((0+1)*3+1)^2/2)^2/2=32$$

Pretty contrived but it kind of forces the solution without exhausting all the possibilities!

• There are two copies of x3. You have only used one. – Nij Apr 24 '20 at 23:28
• A mathematical explanation with useful, formal hints how this kind of problem can be approached. The other x3 is easy to include. – mafu Apr 25 '20 at 5:10

I had a lot of fun with this one! First, as others did, I worked out it could "only" be done starting from one particular number, then saw Glorfindel's answer and realised that if

4 is a waypoint, then so is -4, because -4^2 is also 16.

So I worked backwards from that and found

a new starting point of -8/9.

Then it occurred to me that

all the operations are reversible on the complex plane

so I modified the operations accordingly and wrote a solver, also as an exercise in the C++ STL, tuples, lambdas and all that fancy stuff, wrote the output to a file and fed it into gnuplot.

This is the resulting plot, showing

all 161,280 possible starting points
NB: there are duplicates I haven't removed;
there are more results than 8! (40,320) because a complex number has two square roots

Edit: After posting I found a way to remove duplicates, which if I got the logic right means there are

4950 unique answers, using a difference of 0.0001 in both parts.

Edit: Can I post an example?

32 -1 /3 -sqrt -sqrt -1 *2 *2 /3 = -1.3333 - i2.3906

• What a cool generalization! I love it! – Galen Apr 26 '20 at 19:04
• could you post an example? :) – Rainb Apr 27 '20 at 1:55

In response to the assertion that it cannot be done starting with 1, here is a method that may work, depending on exactly how the rules are applied.

$$(1) \times 3 = 3$$ $$3 + 1 = 4$$ $${4 \div 2} = 2$$ $$2^2 = 4$$ $${4 \div 2} = 2$$ $$2^{2+1 \times 3} = 2^5$$ $$2^5 = 32$$

My answer assumes that an expression starting with "+1" is valid:

(((((+1×3+1)^2)÷2))^2)÷2