# Math Challenge: Create 8

Using only $$2$$, $$7$$, and $$7$$ (each one must be used only once) and only using the operations $$+$$, $$-$$, $$\times$$, $$\div$$, $$\textrm{^}$$, and parentheses, make 8. You can also use decimals.

(7 / .7) - 2

• Maybe someone can confirm with a proof/full explanation of some sort(or prove me wrong!) but I'm fairly confident this is the only solution (besides adding negatives to both numerator and denominator). – TCooper Sep 4 '20 at 22:49
• @TCooper proven you wrong – teed Sep 5 '20 at 5:23
• @deusovi, why are you used brackets? – Nick Sep 5 '20 at 13:03
• @Nick Just for visual clarity. They weren't necessary, but I thought it might make it slightly faster to parse. – Deusovi Sep 5 '20 at 13:20
• Well: Any a / (a * n) where n != 0 results in 'n'. 7 / 0.7 = 7 / (0.7 * 10) = 10. 10 - 2 = 8. Although the zero-less decimal notation is quite controversial over here in Europe! – Battle Sep 5 '20 at 18:02

Under a suitable interpretation of "you can also use decimals", another answer is

$$7 + .\overline7 + .\overline2$$, where the bars represent repeating decimals, so that the expression is $$7 + 0.7777{\ldots} + 0.2222{\ldots}$$.

• Had this in mind, too, but that's a broad interpretation of "decimals". – Michael Hoppe Sep 6 '20 at 13:12
• I would say the problem isn't the deimcals, it uses the digits more than once and/or uses a disallowed operator – TCooper Sep 8 '20 at 17:25
• It's not so clear to me. Why is the decimal point an allowed operator? It's because of our interpretation of the imprecise "You can also use decimals". A repeating bar is a standard notation for repeating decimals, so that seems within a reasonable interpretation to me. – Greg Martin Sep 8 '20 at 20:12

Without allowing any tricks, especially not:

Zeroless decimals, like .7 instead of 0.7

Then here are all the solutions:

There are
no
solutions.

Justification:

import itertools
import operator
d1 = lambda x,y: 10*x + y
d2 = lambda x,y: x + y/10
d3 = lambda x,y: x + y/100
for f,g in itertools.permutations([operator.add, operator.sub, operator.mul, operator.truediv, operator.floordiv, operator.pow, d1,d2,d3, operator.xor]*2, 2):
for x,y,z in itertools.permutations([2,7,7]):
try:
if (g(f(x,y), z) == 8):
print('({} {} {}) {} {}'.format(x,f,y,g,z))
except (ZeroDivisionError, TypeError):
pass
try:
if (g(x, f(y,z)) == 8):
print('{} {} ({} {} {})'.format(x,g,y,f,z))
except (ZeroDivisionError, TypeError):
pass

• This might be the most pedantic answer I've ever seen... but you aren't wrong lol – TCooper Sep 8 '20 at 17:26

Interpreting the constraints as purely typographic:

$$7^{(2)}/7$$
($$x^{(n)}$$ is commonly used to denote the rising factorial $$x(x+1)...(x+n-1)$$)

or (also rather mathsy):

$$7+\left(\frac{2}{7}\right)$$
($$\left(\frac{n}{p}\right)$$ is the Legendre symbol which for a prime $$p$$ and a natural number $$n$$ is defined as $$0$$ if $$p$$ divides $$n$$, as $$1$$ if $$n$$ is a "quadratic residue mod $$p$$", i.e. $$n=a^2 \mod p$$ for some non multiple $$a$$ of $$p$$, and as $$-1$$ if $$n$$ is a quadratic nonresidue mod $$p$$, i.e. no such $$a$$ exists; in our case $$p=7,n=2$$ we could choose $$a$$ to be either $$3$$ or $$4$$)
Unwieldy and arbitrary as this may look the concepts around the Legendre symbol are actually a pillar of elementary and not so elementary number theory.

or, bending the rules a tiny bit (there are many kinds of parentheses):

$$\langle \{7,7+2\} \rangle$$ or $$\langle (7,7+2) \rangle$$ or $$\langle [7,7+2] \rangle$$
(physicists use angular parentheses for averages)

I am not sure if this is mathematically valid but at least it works on my calculator:

$$7^{(.)/2}+7$$ where the lone decimal is interpreted as a zero

• You have to use 2 as well – Lukas Rotter Sep 5 '20 at 16:32
• @LukasRotter not sure that's %100 clear from OP wording ("only once" is not "exactly once"). Besides, once you accept what the calculator accepts it is trivial to make the 2 go away. – Paul Panzer Sep 5 '20 at 16:37
• @LukasRotter As Paul Panzer said, its trivial to use the 2. In fact I edited it to use the 2 as well just in case that's what the OP meant – nobody Sep 5 '20 at 16:40

If we allow the ^ operator to be used refer to the XOR operator $$\oplus$$, we can write:

$$(7 \div .7)\ ^\wedge\ 2$$
This can be interpreted as such.

$$(7 \div .7) \oplus 2$$

• isn't that 100, not 8? – HugoRune Sep 5 '20 at 5:28
• @HugoRune I use ^ as XOR operator, not exponent – teed Sep 5 '20 at 5:30
• @HugoRune I suppose it's fair to call C/C++ (or Python for that matter) a rather common language. – Paul Panzer Sep 5 '20 at 5:43
• Also, but perhaps that's just me, programming is about the only domain where leaving out the leading zero in a decimal fraction is borderline acceptable. – Paul Panzer Sep 5 '20 at 5:51
• Though ⊕ is much more common as a XOR operator, ^ is readily available in ASCII. I have never seen ⩒, ⩛, ↮, and ≢ used in the literature. Also, when in Programmer mode, the Windows built-in calculator uses ^ as XOR in the keyboard. – teed Sep 5 '20 at 8:40

Does $$\lceil7+2/7\rceil$$ count where $$\lceil . \rceil$$ denotes the ceiling function, see https://en.wikipedia.org/wiki/Floor_and_ceiling_functions?

If that doesn't count what about $$7+7^{[.2]}$$ where $$[.]$$ is the rounding function to the next integer?

• Welcome to PSE! - Unfortunately, the question reads "and only using the operations +, -, *, /, ^, and parentheses, make 8." The ceiling function $\lceil x\rceil$ is not listed. – user46002 Sep 5 '20 at 17:26
• Well, in a broad sense $\lceil$ and $\rceil$ look like parenthesis, don't they? ;) – Michael Hoppe Sep 5 '20 at 17:29
• I mean... they are listed under the "Brackets" section of en.wikipedia.org/wiki/List_of_mathematical_symbols#Brackets... didn't know that! :) – user46002 Sep 5 '20 at 17:31