# Using only 1s, make 29 with the minimum number of digits

Use the minimum number of ones to make 29.

Here is the list of operations permitted:

• "Standard" operations, such as: $$x+y$$, $$x-y$$, $$x\times y$$, $$x\div y$$
• Negation: $$-x$$
• Exponentiation of two numbers: $$x^y$$
• The square root of a number: $$\sqrt{x}$$
• The factorial: $$x!$$
• Concatenation of the original digits: $$x|x$$, $$x|x|x$$, $$x|x|x$$, etc. This means that you cannot concatenate like this: $$(1+1)|1 = 2|1 = 21$$

You can only use ones, and the result must be exactly $$29$$, not "about" 29.

You may not use any other operations. That includes $$\log{x}$$, $$\left \lfloor{x}\right \rfloor$$, $$\left \lceil{x}\right \rceil$$ and any others. You must only use base 10, and you not use any decimal points (i.e. no .1, .11, etc.).

The record to beat is 7.

• (1+1+1) / .1 - 1 Feb 28, 2019 at 6:28
• Do you know if there is a solution with less than 7 digits, or are we just hoping there is one? Feb 28, 2019 at 11:01
• @AllanCao Are you, by any chance, a smurf account of one of the regulars? Never have I ever seen such a well-defined formation-of-numbers puzzle with the "new contributor" flag on it. Great job, and welcome to PSE!
– Bass
Feb 28, 2019 at 15:31
• Thank you! I'm not an alt account or anything. As well, I think 6 might be possible but I haven't found a solution. I've only gone down to 7 which I found to be a fun puzzle so I decided to share it. Feb 28, 2019 at 16:29
• I've got a 5-er too... By thinking out of the box quite a bit... Would be fun to post - but not enough rep... Mar 1, 2019 at 21:37

Here's a 7-digit solution:

$$(11-1)\times(1+1+1)-1$$

Searching exhaustively is somewhat complicated. Let's say, broadly, impossible. One is able to take indefinite factorials and raise to ludicrous powers and take arbitrary numbers of square roots. These endeavors would almost certainly lead nowhere but computers don't necessarily know that.

Not only so, but a search that doesn't use symbolic algorithms to handle sqrts and fractions might find something that looks like a solution but is only 29.0000000.

Nonetheless, one can arbitrarily put "reasonable" restrictions on such things and say that we are not going to do, for example, $$a^b$$ unless $$0 and $$-20.

Doing this, I find that there are 28,948 different numbers that can be reached with six 1s. None of them is 29. My code just tracked one solution for each number that it found and spat out the above solution which suggests to me that it's the only one with 7 digits. I haven't tried to do list them all, but if someone else wants to wade through my code it is below

def factorial(n):
if n<=1: return 1
return n*factorial(n-1)

sols={}
sols = {}
sols = "1"
vals = set()

digits=2
while digits<=7:
sols[digits] = {}

#concat
concat = "1"*digits
if eval(concat) not in vals:
sols[digits][eval(concat)] = concat

#simple sum
if digits not in vals:
ssum = "1+"*digits
sols[digits][digits] = ssum[:-1]

#partitions
for part1 in range(1,digits):
part2 = digits-part1
if part1>part2: break
for val1 in sols[part1]:
for val2 in sols[part2]:
#multiply
if val1*val2 not in vals:
sols[digits][val1*val2] = "("+sols[part1][val1]+")*("+sols[part2][val2]+")"
if val1+val2 not in vals:
sols[digits][val1+val2] = "("+sols[part1][val1]+")+("+sols[part2][val2]+")"
#divide
if val2 !=0:
if val1/val2 not in vals:
sols[digits][val1/val2] = "("+sols[part1][val1]+")/("+sols[part2][val2]+")"
if val1 !=0:
if val2/val1 not in vals:
sols[digits][val2/val1] = "("+sols[part2][val2]+")/("+sols[part1][val1]+")"
#subtract
if val1-val2 not in vals:
sols[digits][val1-val2] = "("+sols[part1][val1]+")-("+sols[part2][val2]+")"
if val2-val1 not in vals:
sols[digits][val2-val1] = "("+sols[part2][val2]+")-("+sols[part1][val1]+")"
#exponent
if val1 > 0 and val1 < 1000 and abs(val2)<20:
if val1**val2 not in vals:
sols[digits][val1**val2] = "("+sols[part1][val1]+")^("+sols[part2][val2]+")"
if val2 > 0 and val2 < 1000 and abs(val1)<20:
if val2**val1 not in vals:
sols[digits][val2**val1] = "("+sols[part2][val2]+")^("+sols[part1][val1]+")"

k = list(sols[digits].keys())[:]
for val in k:
#Sqrt
if val>0:
if val**0.5 not in vals:
sols[digits][val**0.5] = "sqrt("+sols[digits][val]+")"
if val==int(val) and val<=20:
if factorial(val) not in vals:
sols[digits][factorial(val)] = "("+sols[digits][val]+")!"

if 29 in vals:
break
#next number
print(digits,len(sols[digits]))
digits+=1

• That is the minimum I achieved by referencing the Single Digit Representations of Natural Numbers paper. Hopefully 6 is possible. Feb 28, 2019 at 2:51
• Do you mean that allowing concatenations should reduce it from 7 to 6? Or are the constraints the same in the paper you cite as in the question above? Feb 28, 2019 at 2:53
• The paper uses different rules. Feb 28, 2019 at 3:04
• I wonder how much CPU power/hour would be needed to catalog all possible 7-digit solutions to this problem Feb 28, 2019 at 19:33
• I'll post my attempt just now if I'm at all successful Mar 1, 2019 at 0:47

I thought I had it with this:

$$\sqrt{((1+1+1)!)!+11^{1+1}}$$.

Until I remembered that

there's no function to square a number without using any digits, even though there is a function to take a square root without using any extra digits. For the past hour I've been trying to figure out how to square a number just using the square root.
Since square root is a number raised to the power of $$\frac{1}{2}$$, I'm wondering if I can just take a reciprocal of that for a total of six 1s. My guess is that this isn't allowed because there isn't a way to actually write this down!
$$\sqrt{((1+1+1)!)!+11^{\frac{1}{1/2}}}$$

• Curious thing: if $f$ denotes a function (or operation), the inverse operation is commonly denoted by $f^{-1}$ (it is not an exponentiation). So, you might denote as ${\sqrt{}}^{-1}$ the inverse operation to square root (i.e. squaring, thus using only one 1). Of course, it is probably not permitted by the rules. Feb 28, 2019 at 8:57
• Note that $3!! = 3 \times 1$ not $(3!)!$ and adding more parentheses makes your first solution a good 7. Feb 28, 2019 at 9:23
• @WeatherVane I didn't realize that double factorial had a different meaning. Of course I meant the iterated factorial. I'll add the parenthesis. Feb 28, 2019 at 14:57
• What about negative exponents? Feb 28, 2019 at 20:18
• I like how multifactorials break every rule of math notation. Mar 1, 2019 at 18:48

As stated by luchonacho, exhaustion will show that it's not possible in less than 7 digits with those operations.

Not showing negative values, as they are symmetric to positive ones, here are the easy attainable integer values:

1 digit:  1
2 digits: 0, 2, 11, 11!, ...
3 digits: 3, 6, 10, 12, 111, 720, 10!, ...
4 digits: 4, 5, 7, 9, 13, 22, 24, 110, 112, 120, 121, 719, 721, 1111, ...
5 digits: 8, 14, 17, 20, 21, 23, 25, 33, 36, 64, 66, 100, 109, 113, 119, 122, 132, 144, 222, 360, ...


And now we know we're stuck, because to achieve 29 (a prime number) in 6 digits, we would actually need any of those values in 5 digits: 28, 30, 784, 900, ... and we don't have them.

As such, any solution for 29 in 7 digits is optimal:

29 = (11−1)×(1+1+1)−1 (found by Dr Xorile)

Note that there may be room for a non-trivial sum of factorial numbers to reach a square power of 29 (or of 29±1), as found by Amorydai, but it's unlikely to beat 7 digits.

For illustration, while all values below 27 are attainable trivially with 6 digits or less, here are some solutions in 7 digits for numbers greater or equal to 28:

28 in 7 digits = (1+1+1)^(1+1+1)+1
28 in 7 digits = (1+1)×(11+1+1+1)
29 in 7 digits = (11−1)×(1+1+1)−1
30 in 6 digits = (11−1)×(1+1+1)
31 in 7 digits = (11−1)×(1+1)+11
31 in 7 digits = (11−1)×(1+1+1)+1
31 in 7 digits = (1+1+1)×11-1-1
32 in 6 digits = (1+1+1)×11-1
33 in 5 digits = (1+1+1)×11
34 in 6 digits = (1+1+1)×11+1
35 in 6 digits = (1+1+1)!^(1+1)-1
36 in 5 digits = (1+1+1)!^(1+1)
37 in 6 digits = (1+1+1)!^(1+1)+1
38 in 7 digits = (1+1+1)!^(1+1)+1+1
39 in 7 digits = (11+1+1)×(1+1+1)
40 in 7 digits = (11-1)×(1+1+1+1)
40 in 7 digits = (11-1)×(1+1)×(1+1)

15 is the lowest positive value requiring 6 digits with this reasoning.
28 is the lowest positive value requiring 7 digits with this reasoning.
41 is the lowest positive value requiring 8 digits with this reasoning.

• The claim that it's impossible to reach 29 by some iterated factorial, followed by a trivial addition/subtraction, followed by an iterated square root, might be very hard to prove (and necessary, because factorial and square root are free actions in this ruleset). Feb 28, 2019 at 23:18
• @Brilliand in x! ± 1, you never have a divisor lower than x, so subsequent square roots will always have a factor greater than x itself.
– Cœur
Mar 1, 2019 at 1:52
• @Cœur could you add two factorials then modify the result? I would hazard a guess that you could find something that roots to a factor smaller than x. Unlikely whether that would be doable in less than 6 though, more as a counterexample to that proof.
– user18141
Mar 1, 2019 at 4:52
• Note that you can get 27 = (1+1+1)^(1+1+1) for 6 digits. Just for your illustration! Mar 1, 2019 at 9:15
• @Riker I just realized adding/subtracting two different factorials won't work for this. The sum x!+y! (or x!-y!) will always be divisible by the smaller of x! or y!, hence divisible by 2 (provided neither x nor y is 1), and no iterated square of 29 is divisible by 2. That limits the possible "trivial addition/subtraction"s to a fairly small set. Mar 4, 2019 at 20:41

I managed three 8's:

$$(1+1+1+1)!+(1+1+1)!-1=24+6-1$$
$$(1+1+1)!\times((1+1+1)!-1)-1=6\times(6-1)-1$$
$$(11+1+1+1)\times(1+1)+1=14\times2-1$$

and a very dodgy 6:

$$11!!!!!!!!-(1+1+1+1)=11\times3-4$$

and 4:

$$(11-1)!!!!!!!-1=10\times3-1$$

• ... I don't think that's how factorial works. I'm very sure that is not how factorial works. Feb 28, 2019 at 8:43
• @AllanCao I believe JonMark Perry is using extended factorial functions. For example, a double factorial is defined to be $n(n-2)(n-4)(n-6)...(3)(1)$ if $n$ is odd, and $n(n-2)(n-4)(n-6)...(4)(2)$ if $n$ is even. If we're calculating a triple-factorial, that evaluates to $n(n-3)(n-6)(n-9)...$. In the case of $(11 - 1)!!!!!!!$ (a seven-factorial), it simplifies like this: $(11 - 1)!!!!!!! = (10)!!!!!!! = (10)(10-7) = (10)(3) = 30$ Feb 28, 2019 at 8:50
• I see. Since they aren't really factorial (and kind of cheating/cheap), the solution for 6 and 4 don't work. Feb 28, 2019 at 16:51
• multi-factorial, but in most 24-type games they are considered to be a big cheat!!! mind you, so is (1+1).concat(11-1-1). @AllanCao
– JMP
Feb 28, 2019 at 17:07
• Which is why the concatenation is only for the original digit. Feb 28, 2019 at 17:18

According to my analysis, there is no solution using less than 7 digits. The proof would require an exhaustion of every possible operation from 29, reducing the dimensionality of the problem one digit at a time, like a tree. I haven't followed all the leaves of the tree, but it seems clear no one leads to a solution.

To see how my logic works, consider an example:

$$29 + 1 = 30$$

Here we have a sub problem, which is to find a way to get to 30 using 5 or less digits. You can then follow the leaves of the tree, reducing the dimensionality one at a time, until you see there is no solution. For example, 30 + 1 = 31, and finding 31 from 4 digits, etc. Or 30 + 11 = 41, and so on.

Importantly, many of the branches of the original problem are identical. For example, $$29 + 1 = 30$$ is the same as $$29+1! = 30$$; and the subbranch above $$30 + 1 = 31$$ is exactly the same as $$29+(1+1) = 31$$ and $$29+(1+1)! = 31$$.

Same logic applies to, for instance, $$29-1=28$$. You need to get to 28 using 5 digits. Following the branches seem to lead to nowhere.

Some routes are evidently discarded. For instance, 11! = 39916800, too high. Would need to be scaled with a relatively high number, like 111. But that uses 5 of 6 digits. No way to use the last one meaningfully. Same logic with 111! or other like (11-1)! Other routes, like (1+1+1)!=6, requires you to produce 23 (so 23+6=29) with only 3 digits. Impossible.

No idea why you would ever consider square root as a relevant operation. Temptation here is that somehow a squared root times a natural number ($$\sqrt{a}b$$) will give a natural number. However, this is only true if $$ab^2$$ is itself the square of a natural number. So you should start by searching for the latter. For example, take 36. It's the square of 6. Can you find natural numbers a and b such that $$ab^2=36$$? Yes, a=4 and b=3, or a=9 and b=2. But these use too many digits. Follow down the tree and you are done very quickly. What about a=11? It can be seen that it is not possible to find a natural number b such that $$\sqrt{11b^2}$$ is a natural number.

The above applies the same with division, e.g. $$\frac{\sqrt{a}}{b}$$ or $$\frac{b}{\sqrt{a}}$$ routes.

I haven't given you any proof of my claim and I might be totally wrong. But my methodology (reducing the dimensionality of the problem one at a time) led me to nowhere.

• My solution for 7 digits uses a square root quite nicely. Feb 28, 2019 at 15:15
• @Amorydai True. I did overlook something like $\sqrt{a+b}$, focusing instead only on multiplicative forms, like $\sqrt{ab}$. I just had another go from derivations of yours, and it seems impossible to reduce it 1 digit. I could be wrong! As I said, I cannot offer proof, only failed trials. I do not want to go down every possible branch of the tree, even though it is possible. Feb 28, 2019 at 16:49
• The only cases where $\sqrt{a}b$ is a natural with both $a$ and $b$ natural are when $a$ is already a square, or when $b=0$. Feb 28, 2019 at 18:25
• Your "reducing the dimensionality one at a time" logic fails to account for the possibility of combining two expressions that both use more than one digit. For example, $(1+1+1)(1+1+1)$ cannot be decomposed into a 5-digit expression and a 1-digit expression. Feb 28, 2019 at 18:26
• @user2357112 True, but to the extent that these expressions have to be multiplied or added to other terms in order to reach 29, they are covered in my examples. For instance, your example gives a 9. That is precisely one of my examples, where $a=9$ and $b=2$. In case of addition/substraction, you still need to get to 20 (29-9) or 38 (29+9) using the remaining digits. Mar 1, 2019 at 9:02

I can get an answer accurate to within 0.12% with six 1s:

$$\sqrt{\sqrt{\sqrt{11^{11}}}}+1+1 \approx 29.0343$$

• Interesting approach to the question but an exact answer is required. Feb 28, 2019 at 7:25

Lowest I managed so far is 9 digits:

• (1 + 1 + 1 + 1)! + 1 + 1 + 1 + 1 + 1;

• 11*(1 + 1 + 1) - (1 + 1 + 1 + 1)

Some other ways I came up with:

• (1 + 1)^(1 + 1 + 1 + 1 + 1) - 1 - 1 - 1 (10 digits)

• (1 + 1 + 1 + 1 + 1)!/(1 + 1 + 1 + 1) - 1 (10 digits)

• (1 + 1 + 1 + 1 + 1)^(1 + 1) + 1 + 1 + 1 + 1 (11 digits)

• 11*(1 + 1) + 1 + 1 + 1 + 1 + 1 + 1 + 1 (11 digits)

• Looking at your first 10 and 11 digit solutions, can't you simplify to (1+1+1)^(1+1+1)+1+1 for 8 digits? Feb 28, 2019 at 10:07
• @Chronocidal: Less simplified and more a different solution... Feb 28, 2019 at 14:44

This was posted before the question was edited to demand an integer, and requires that the rules accept rounding, but it does produce the digits 29. Six is achievable in this way:

$$\sqrt{( ( 1 + 1 + 1 )! + 1 )} * 11 \approx 29.1033$$

• Interesting approach to the question but an exact answer is required. Feb 28, 2019 at 7:25
• You could fix it with the floor: $\lfloor\sqrt{( ( 1 + 1 + 1 )! + 1 )} * 11\rfloor = 29$ Mar 1, 2019 at 0:11
• Floor can't be used. As well, I just assumed that people would take 29 as exactly 29 not around 29. Mar 1, 2019 at 5:57
• Well, as the problem originally stated "make 29" without an explicit restriction to an exact integer result, asking on a puzzling site where people enjoy posting creative/stretch answers will bring one to accept such responses. Before the restriction was imposed, the multiple definitions of "make" might not rule out extra digits appearing. Mar 2, 2019 at 0:33

For the sake of completeness, here's an 8 digit solution:

(1+1+1)^(1+1+1) + 1 + 1

11+11+11-1-1-1-1=29 This is my best guess.

• Even 11 * (1+1+1) is better for the beginning. Feb 28, 2019 at 7:22