# The game of Sevens

There is a popular game, named Four fours, where you have to find the shortest mathematical expression for every number from $1$ to $n$, using only the number $4$ and some operators.

My variant of this game is named Sevens, and you can only use the number $7$ and some math operators to obtain the other numbers.

Here is a list of accepted operators (along with their individual score):

• $+,-,\times, \div$ (one point)
• Parenthesis $( \ )$ (zero points)
• Exponentiation (one point)
• Square root) $\surd$ (rounded to lower integer) (two points)
• Factorial $!$ (two points)

Note: Logarithms and concatenation are explicitly not allowed! Implicit multiplication isn't allowed (eg. 7(3))

How to calculate the score?
The total score is the sum of all the partial scores you get with operations.
If you use an operation twice, you must add the partial score twice, of course.
The lower the score, the better it is!

Examples:
$7=(7+7)-7$ results in a score of $2$
$7=(7!)/(7-7/7)!$ results in a score of $7$

Your task is to generate the numbers from $1$ to $30$ achieving the minimum possible score, using only the number $7$ and the above operations.

• Is there a limit on the number of operators allowed to be used (similar to Four fours)? – Mark N Apr 27 '15 at 14:35
• @MarkN It is an optimisation puzzle. You must find the best solution, not just any one that meets the limit. So, no, no limit. – ghosts_in_the_code Apr 27 '15 at 14:38
• Shouldn't you also place the restriction that you must use exactly seven 7s? Otherwise, why bother calling the game "Seven Sevens"? – Ian MacDonald Apr 27 '15 at 14:43
• @leoll2 The game Four Fours also (usually) has the restriction that the player must use four 4s in each equation. That's why it's named Four Fours. – Ian MacDonald Apr 27 '15 at 15:03
• @JLee I've just renamed it to avoid confusion – leoll2 Apr 27 '15 at 15:20

Here are my new answers, once again taking as base the Mark N contribution, but this time not using the binomial coefficient.

Score: 107

$1 = \frac{7}{7}$ [Score +1]

$2 = \sqrt{7}$ [Score +2]

$3 = \sqrt{7+7}$ [Score +3]

$4 = \sqrt{7+7+7}$ [Score +4]

$5 = 7-\sqrt{7}$ [Score +3]

$6 = 7-\frac{7}{7}$ [Score +2]

$7 = 7$ [Score +0]

$8 = 7+\frac{7}{7}$ [Score +2]

$9 = 7+\sqrt{7}$ [Score +3]

$10 = 7+\sqrt{7+7}$ [Score +4]

$11 =\sqrt{\sqrt{7}^7}$ [Score +5]

$12 = 7+7-\sqrt{7}$ [Score +4]

$13 = 7+7-\frac{7}{7}$ [Score +3]

$14 = 7 + 7$ [Score +1]

$15 = 7 + 7 + 7/7$ [Score +3]

$16 = 7 + 7 + \sqrt{7}$ [Score +4]

$17 = 7 + 7 +\sqrt{7+7}$ [Score +5]

$18 = \sqrt{7*7*7}$ [Score +4]

$19 = 7+7+7-\sqrt{7}$ [Score +5]

$20 = 7+7+7-\frac{7}{7}$ [Score +4]

$21 = 7+7+7$ [Score +2]

$22 = 7+7+7+\frac{7}{7}$ [Score +4]

$23 = 7+7+7+\sqrt{7}$ [Score +5]

$24 = (\sqrt{7+7+7})!$ [Score +6]

$25 = \frac{7*7*7+7}{7+7}$ [Score +5]

$26 = \sqrt{7!/7}$ [Score +5]

$27 = 7+7+7+7-\frac{7}{7}$ [Score +5]

$28 = 7+7+7+7$ [Score +3]

$29 = 7+7+7+7+\frac{7}{7}$ [Score +5]

$30 = \sqrt{\sqrt{7^7}}$ [Score +5]

• I accept this answer as it looks optimal. If anybody comes with a better solution, I will accept his. – leoll2 May 18 '15 at 12:01

So, here's a foundation to start on. Score: 109

$1 = 7/7$ [Score +1]

$2 = (7+7)/7$ [Score +2]

$3 = (7+7+7)/7$ [Score +3]

$4 = 7-(7+7+7)/7$ [Score +4]

$5 = 7-(7+7)/7$ [Score +3]

$6 = 7-7/7$ [Score +2]

$7 = 7$ [Score +0]

$8 = 7+7/7$ [Score +2]

$9 = 7+(7+7)/7$ [Score +3]

$10 = 7+(7+7+7)/7$ [Score +4]

$11 = 7+7-(7+7+7)/7$ [Score +5]

$12 = 7+7-(7+7)/7$ [Score +4]

$13 = 7+7-(7/7)$ [Score +3]

$14 = 7 + 7$ [Score +1]

$15 = 7 + 7 + 7/7$ [Score +3]

$16 = 7 + 7 + (7+7)/7$ [Score +4]

$17 = 7 + 7 +(7+7+7)/7$ [Score +5]

$18 = 7 + 7 + (7+7+7+7)/7$ [Score +6]*

$19 = 7+7+7-(7+7)/7$ [Score +5]

$20 = 7+7+7-(7/7)$ [Score +4]

$21 = 7+7+7$ [Score +2]

$22 = 7+7+7+(7/7)$ [Score +4]

$23 = 7+7+7+(7+7)/7$ [Score +5]

$24 = 7+7+7+(7+7+7)/7$ [Score +6]

$25 = 7+7+7+7-(7+7+7/7)$ [Score +7]*

$26 = 7+7+7+7-(7+7)/7$ [Score +6]

$27 = 7+7+7+7-(7/7)$ [Score +5]

$28 = 7+7+7+7$ [Score +3]

$29 = 7+7+7+7+(7/7)$ [Score +5]

$30 = 7+7+7+7+(7+7)/7$ [Score +6]

[1+2+3+4+3+2]+0+[2+3+4+5+4+3]+1+[3+4+5+6+5+4]+2+[4+5+6+7+6+5]+3+[5+6] = 113

This is a simple answer to help get the ball rolling.

After improvements:

*$18 = \sqrt{7*7*7}$ [Score +4] (oppose to 6)

*$25 = (7*7*7+7)/(7+7)$ [Score +5] (oppose to 7)

Score: 113 - 2 - 2 = 109

• I've just updated the problem extending the numbers from 20 to 30, it seemed a bit too easy. – leoll2 Apr 27 '15 at 15:24
• Here is an improvement: 18. $\sqrt{7*7*7}$ [Score + 4] – Trenin Apr 27 '15 at 15:31
• Wouldn't $25=5*5$ be better? – Trenin Apr 27 '15 at 16:16
• @Trenin, #5 * #5 would score (3 + 1 + 3), which is the same and I can't use square :( But the idea helps! – Mark N Apr 27 '15 at 16:25
• (7 * 7 * 7 + 7) / (7 + 7) = 25 with a score of 5. – blakeoft Apr 27 '15 at 16:48

Here are my answers, which are a combination of some prior answers and my improvements on certain ones:

Score: 92

$1 = \frac{7}{7} \ \ \ \$ [Score +1]

$2 = \sqrt{7} \ \ \ \$ [Score +2]

$3 = \sqrt{7+7} \ \ \ \$ [Score +3]

$4 = \sqrt{7+7+7} \ \ \ \$ [Score +4]

$5 = 7-\sqrt{7} \ \ \ \$ [Score +3]

$6 = 7-\frac{7}{7} \ \ \ \$ [Score +2]

$7 = 7 \ \ \ \$ [Score +0]

$8 = 7+\frac{7}{7} \ \ \ \$ [Score +2]

$9 = 7+\sqrt{7} \ \ \ \$ [Score +3]

$10 = 7+\sqrt{7+7} \ \ \ \$ [Score +4]

$11 =\sqrt{7(7)7} \ - \ 7 \ \ \ \$ [Score +3]

$12 = 7+7-\sqrt{7} \ \ \ \$ [Score +4]

$13 = 7+7-\frac{7}{7} \ \ \ \$ [Score +3]

$14 = 7 + 7 \ \ \ \$ [Score +1]

$15 = 7 + 7 + 7/7 \ \ \ \$ [Score +3]

$16 = 7 + 7 + \sqrt{7} \ \ \ \$ [Score +4]

$17 = \sqrt{7(7(7) - 7)} \ \ \ \$ [Score +3]

$18 = \sqrt{7(7)7} \ \ \ \$ [Score +2]

$19 = \sqrt{7(7)7 + 7(7)} \ \ \ \$ [Score +3]

$20 = 7+7+7-\frac{7}{7} \ \ \ \$ [Score +4]

$21 = 7+7+7 \ \ \ \$ [Score +2]

$22 = 7+7+7+\frac{7}{7} \ \ \ \$ [Score +4]

$23 = 7+7+7+\sqrt{7} \ \ \ \$ [Score +5]

$24 = \sqrt{(7(7) - 7)(7 + 7)} \ \ \ \$ [Score +4]

$25 = \sqrt{7(7)7} \ + \ 7 \ \ \ \$ [Score +3]

$26 = \sqrt{7(7)7 \ + \ 7(7)7} \ \ \ \$ [Score +3]

$27 = \sqrt{(7(7) + 7)7 \ + \ 7(7)7} \ \ \ \$ [Score +4]

$28 = 7+7+7+7 \ \ \ \$ [Score +3]

$29 = 7+7+7+7+\frac{7}{7} \ \ \ \$ [Score +5]

$30 = \sqrt{\sqrt{7^7}} \ \ \ \$ [Score +5]

[1 + 2 + 3 + 4 + 3 + 2] + [0 + 2 + 3 + 4 + 3 + 4] + [3 + 1 + 3 + 4 + 3 + 2] + [3 + 4 + 2 + 4 + 5 + 4] + [3 + 3 + 4 + 3 + 5 + 5] = 92

. .

The above solution will have to be accepted as best so far, else the problem poser is a cheat.

$1=7/7$

$2=(7+7)/7$

$6=7-7/7$

$7=7$

$8=7+7/7$

$14=7+7$

• i got the same thing for 7 :) – JLee Apr 27 '15 at 14:37

Taking Mark N answer (thanks a lot) I'll try to improve a bit, using some lateral thinking with the parentesis. Still, most of the credit goes to him.

EDIT: I decided to think even further outside the box and use $.7$ notation to improve the score.

Score: 73

$1 = \binom{7}{7}$ [Score +0]

$2 = \binom{7}{7}+\binom{7}{7}$ [Score +1]

$3 = \binom{7}{7}+\binom{7}{7}+\binom{7}{7}$ [Score +2]

$4 = \binom{7}{7}+\binom{7}{7}+\binom{7}{7}+\binom{7}{7}$ [Score +3]

$5 = 7-\binom{7}{7}-\binom{7}{7}$ [Score +2]

$6 = 7-\binom{7}{7}$ [Score +1]

$7 = 7$ [Score +0]

$8 = 7+\binom{7}{7}$ [Score +1]

$9 = 7+\binom{7}{7}+\binom{7}{7}$ [Score +2]

$10 = \frac{7}{.7}$ [Score +1]

$11 = \frac{7}{.7}+\binom{7}{7}$ [Score +2]

$12 = \frac{7}{.7}+\binom{7}{7}+\binom{7}{7}$ [Score +3]

$13 = 7+7-\binom{7}{7}$ [Score +2]

$14 = 7 + 7$ [Score +1]

$15 = 7 + 7 +\binom{7}{7}$ [Score +2]

$16 = 7 + 7 + \binom{7}{7}+\binom{7}{7}$ [Score +3]

$17 = \sqrt{\binom{7+7}{7}^.7}$ [Score +4]

$18 = \sqrt{7*7*7}$ [Score +4]

$19 = \frac{7+7}{.7}-\binom{7}{7}$ [Score +3]

$20 = \frac{7+7}{.7}$ [Score +2]

$21 = \binom{7}{\binom{7}{7}+\binom{7}{7}}$ [Score +1]

$22 = \binom{7}{\binom{7}{7}+\binom{7}{7}}+\binom{7}{7}$ [Score +2]

$23 = \binom{7}{\binom{7}{7}+\binom{7}{7}}+\binom{7}{7}+\binom{7}{7}$ [Score +3]

$24 = (7+\binom{7}{7})*(\binom{7}{7}+\binom{7}{7}+\binom{7}{7})$ [Score +4]

$25 = (7*7*7+7)/(7+7)$ [Score +5]

$26 = \sqrt{7!/7}$ [Score +5]

$27 = 7+7+7+7-\binom{7}{7}$ [Score +4]

$28 = 7+7+7+7$ [Score +3]

$29 = 7+7+7+7+\binom{7}{7}$ [Score +4]

$30 = \frac{7+7+7}{.7}$ [Score +3]

I'll be editing and improving when I come up with new ones.

• The binomial coefficient isn't in the list of accepted operators. If you want to use it, you must build it with factorials. – leoll2 May 16 '15 at 11:12
• I just wanted to think a bit outside the box. I'll post another more canonical answer. – Masclins May 16 '15 at 15:06
• Ithink it breaks the 'spirit' of the puzzle, but I enjoy your lateral thinking on the parentheses notation. – Spencerkatty May 16 '15 at 17:10
• also 7 above 7 is still 7/7 so thats 1 point whenever you use it – Vajura May 18 '15 at 10:30
• @Vajura as said I tried to be a bit creative in here when using the parentheses. leoll2 clearly said that binomial coefficient is not an accepted operator so the answer is only kept as curiosity, with no intention of being the best solution to the puzzle. – Masclins May 18 '15 at 10:32