# Creating 123456 in the fewest number of steps

You start with the number 1. You can create a new number by applying an operation on two existing numbers (can be the same). The operations are +, - and *. What is the fewest number of steps needed to reach the number 123456? Bonus question: can you find multiple solutions?

Here is a similar puzzle: Creating 2020 in the fewest number of steps

Good luck!

I have found some 9 step solutions

1.

1 + 1 = 2
2 + 1 = 3
3 * 2 = 6
6 * 3 = 18
18 + 1 = 19
19 * 18 = 342
342 + 19 = 361
361 * 342 = 123462
123462 - 6 = 123456

2.

1 + 1 = 2
2 + 1 = 3
3 * 2 = 6
6 * 3 = 18
18 + 1 = 19
19 * 18 = 342
342 * 19 = 6498
6498 * 19 = 123462
123462 - 6 = 123456

3.

1 + 1 = 2
2 + 1 = 3
3 * 2 = 6
6 * 3 = 18
18 + 1 = 19
19 * 19 = 361
361 * 19 = 6859
6859 * 18 = 123462
123462 - 6 = 123456

• Great work! This is the solution I had in mind. I wonder if it can be improved? – Dmitry Kamenetsky Dec 19 '19 at 8:09
• I am actually trying to simulate it on a computer. lets see If I find a better one. – sudhackar Dec 19 '19 at 8:10
• 9 seems to be the lower bound for what I see from the simulation – sudhackar Dec 19 '19 at 8:11
• I made a program to find all solutions and it didn't found the 8 step solution so nine step is minimum and 10 solutions exists – Jirka Picek Dec 19 '19 at 9:25
• Yea. The closest I got was to get 6*(19*19*19*3-1) to represent in 9 steps. – sudhackar Dec 19 '19 at 9:42

Minimum of steps is

9

I found 10 solutions:

Solution 1

1 + 1 = 2
1 + 2 = 3
3 * 2 = 6
6 * 3 = 18
18 + 1 = 19
19 * 18 = 342
342 + 19 = 361
361 * 342 = 123462
123462 - 6 = 123456

Solution 2

1 + 1 = 2
2 + 1 = 3
3 * 2 = 6
6 * 3 = 18
18 + 1 = 19
19 * 18 = 342
342 * 19 = 6498
6498 * 19 = 123462
123462 - 6 = 123456

Solution 3

1 + 1 = 2
2 + 1 = 3
3 * 2 = 6
6 * 3 = 18
18 + 1 = 19
19 * 19 = 361
361 * 18 = 6498
6498 * 19 = 123462
123462 - 6 = 123456

Solution 4

1 + 1 = 2
2 + 1 = 3
3 * 2 = 6
6 * 3 = 18
18 + 1 = 19
19 * 19 = 361
361 - 19 = 342
342 * 361 = 123462
123462 - 6 = 123456

Solution 5

1 + 1 = 2
2 + 1 = 3
3 * 2 = 6
6 * 3 = 18
18 + 1 = 19
19 * 19 = 361
361 * 19 = 6859
6859 * 18 = 123462
123462 - 6 = 123456

Solution 6

1 + 1 = 2
2 + 1 = 3
3 + 3 = 6
6 * 3 = 18
18 + 1 = 19
19 * 18 = 342
342 + 19 = 361
361 * 342 = 123462
123462 - 6 = 123456

Solution 7

1 + 1 = 2
2 + 1 = 3
3 + 3 = 6
6 * 3 = 18
18 + 1 = 19
19 * 18 = 342
342 * 19 = 6498
6498 * 19 = 123462
123462 - 6 = 123456

Solution 8

1 + 1 = 2
2 + 1 = 3
3 + 3 = 6
6 * 3 = 18
18 + 1 = 19
19 * 19 = 361
361 * 18 = 6498
6498 * 19 = 123462
123462 - 6 = 123456

Solution 9

1 + 1 = 2
2 + 1 = 3
3 + 3 = 6
6 * 3 = 18
18 + 1 = 19
19 * 19 = 361
361 - 19 = 342
342 * 361 = 123462
123462 - 6 = 123456

Solution 10

1 + 1 = 2
2 + 1 = 3
3 + 3 = 6
6 * 3 = 18
18 + 1 = 19
19 * 19 = 361
361 * 19 = 6859
6859 * 18 = 123462
123462 - 6 = 123456

Program which I made in C#:

using System;
using System.Collections.Generic;
using System.Linq;

namespace LowestPossible
{
class Program
{
const int NUMBER_TO_FIND = 123456;
const int MAX_DEPTH = 10;

public static void Main()
{
var list = new List<Tuple<int, string>>();
rec(list, 1);
}

public static void rec(List<Tuple<int, string>> row, int step)
{
var lastRes = row.LastOrDefault();
if (lastRes.Item1 == NUMBER_TO_FIND)
{
Console.WriteLine(String.Join("", row.Select(a => a.Item2 + " = " + a.Item1.ToString())) + " <" + (step-1) + ">");
return;
}

if (step == MAX_DEPTH || lastRes.Item1 < 1)
{
return;
}

foreach (var num in row)
{
var newRow = new List<Tuple<int, string>>(row);
newRow.Add(new Tuple<int, string>(lastRes.Item1 + num.Item1, " + " + num.Item1));
rec(newRow, step + 1);
newRow.RemoveAt(step);
newRow.Add(new Tuple<int, string>(lastRes.Item1 - num.Item1, " - " + num.Item1));
rec(newRow, step + 1);
newRow.RemoveAt(step);

newRow.Add(new Tuple<int, string>(lastRes.Item1 * num.Item1, " * " + num.Item1));
rec(newRow, step + 1);
newRow.RemoveAt(step);
}
}
}
}


The output does not have nice format but it was made only for me. Also code is optimized to run in dotnetfiddle, but originaly it was for 2020 question. It runs too long for this question so it doesn't work for this one in dotnetfiddle due to timeout.

• There are multiple duplicates here, you can minimize that to 5 imo - like 5 and 10. – sudhackar Dec 19 '19 at 9:26
• Also is this the script? puzzling.stackexchange.com/a/92104/44046 – sudhackar Dec 19 '19 at 9:35
• I agree that getting 6 by 3+3 or 3*2 is nearly the same but it should be different solution since another operation is used – Jirka Picek Dec 19 '19 at 9:36
• No it's not the script, I made my own yesterday for that question but I didn't have time to publish the result and when I wanted to do so today, it was already published... I'll publish it later today – Jirka Picek Dec 19 '19 at 9:38
• Made a pretty substantial edit suggestion, feel free to reject and take parts if you like it – Cireo Dec 20 '19 at 7:37

I've found a 10-step solution:

 1 + 1 = 2
2 + 1 = 3
3 + 1 = 4
4 + 4 = 8
8 * 8 = 64
8 + 2 = 10
64 * 10 = 640
640 + 3 = 643
643 * 3 = 1929
1929 * 64 = 123456


• Bravo. I figured out the 1929 trick, but couldn't make 1929 in few steps. – Victor Stafusa Dec 18 '19 at 23:06
• Math is hard, I agree. Seeing as how I sometimes calculate 0 times 3 = 3. – Avi Dec 18 '19 at 23:15
• Waiting for sw solution to prove it is optimal solution or find better one. – z100 Dec 19 '19 at 0:02
• Very nice work! – Dmitry Kamenetsky Dec 19 '19 at 0:06
• @gustavovelascoh You can only use numbers you've already generated - the result of step 2 is useful later on, in steps 8 and 9. – Avi Dec 19 '19 at 9:23

I believe I can do it in 11 steps

1+1=2
2+2=4
4x4=16
16+16=32
16-1=15
16x16=256
256*15=3840
256*256=65536
65536-3840=61696
61696+32=61728
61728+61728=123456

On reflection I'm not sure this is the least steps, it's getting there though.

123455 steps

1+1=2
2+1=3
4=3+1
1+4=5
6=1+5
6+1=7
8=7+1
8+1=9
1+9=10
10+1=11
1+11=12
...
1+2023=2024
2025=1+2024
2025+1=2026
...
123452=1+123451
1+123452=123453
123454=123453+1
123455=1+123454
123454+1=123456

• You can save a step by using "+2" on the second to last step. – Thomas Markov Dec 19 '19 at 17:49
• You can add a step by using "+2" on the last step and then "-1". – user253751 Dec 20 '19 at 16:38

Let's get the ball rolling. I doubt this is the fewest possible steps, but it should give people a baseline to try to beat.

Total steps: 12

$$1 + 1 = 2\\ 2 + 2 = 4\\ 4 + 4 = 8\\ 8 \times 8 = 64\\ 64 \times 8 = 512\\ 64 \times 64 = 4096\\ 4096 \times 2 = 8192\\ 4096 \times 8 = 32768\\ 32768 \times 4 = 131072\\ 131072 - 8192 = 122880\\ 122880 + 512 = 123392\\ 123392 + 64 = 123456\\$$

Two different 10-step solutions I found (without programming) are:

1 + 1 = 2
1 + 2 = 3
2 + 2 = 4
4 + 4 = 8
2 + 8 = 10
8 * 8 = 64
3 * 64 = 192
64 * 10 = 640
640 + 3 = 643
192 * 643 = 123456

and

1 + 1 = 2
2 + 2 = 4
4 + 2 = 6
4 * 4 = 16
16 * 16 = 256
256 - 1 = 255

16 * 6 = 96
255 + 96 = 351

351 * 351 = 123201
123201 + 255 = 123456

A 9 step solution that doesn't use subtraction:

1+1 = 2
2+2 = 4
4*4 = 16
16+4 = 20
20+4 = 24
16*16 = 256 or 16*20 = 320
256*20 = 5120 or 320*16 = 5120
5120+24 = 5144
5144*24 = 123456

Another 9 step solution nobody has mentioned:

1+1 = 2
2+2 = 4
2+4 = 6
4*4 = 16
16*6 = 96
96-16 = 80 or 16-96 = -80
16*80 = 1280 or 16*-80 = -1280
1280+6 = 1286 or 6 - (-1280) = 1286
1286*96 = 123456

• Beautiful and original! After seeing this I removed the tick. So it's back up for grabs. – Dmitry Kamenetsky Dec 21 '19 at 8:00
• My search found only these and the ones Jirka/sudhacker found (plus minor variants on those, such as swapping the order of 6/16). However, I constrained my search to numbers between -140000 and 140000, so there may be additional answers that go outside those bounds. – Mark Tilford Dec 22 '19 at 12:26
• My random search got these too, but somehow I did not minimize. – sudhackar Dec 24 '19 at 7:46
• My code: function rseek (ar) { if (ar[ar.length-1] == 123456) { console.log(ar+""); return; } if (ar.length == 10) return; var successes = get_nexts(ar); for (var a in successes) { if (-140000 <= a && a <= 140000) { ar.push (a-0); rseek(ar); ar.pop(); } } } function get_nexts(list) { var rv = {}; for (var a of list) for (var b of list) rv[a+b] = rv[a*b] = rv[a-b] = 1; for (var a of list) delete rv[a]; return rv; } – ralphmerridew Jan 10 '20 at 21:57

$$6*6=36$$
$$36*4=144$$
$$144*144=20736$$
$$20736*6=124416$$
$$5*6=30$$
$$30*30=900$$
$$30*2=60$$
$$900+60=960$$
$$124416-960=123456$$