# Half and Double Value

A 3 year old child tried to input or copy a number (written on the paper) to a calculator but he messed up with the digit places. All the digits are there but the value of the number he inputed becomes double. He tried to redo it. Unfortunately the digits are not on the right places again. But this time the value of the number he input is only half of the number he is trying to copy. When he grew older and learned about that early numeral experience the child wondered and asked: What is the smallest positive integer N where its value becomes half or double when its digits are rearranged?

285714­­­­­­­­­­­­­­­­­­­­­­­­

I used the following k program to compute it:

2*{~1=#?{x@<x}'$1 2 4*x}(1+)/1 {...}(1+)/1 means start from 1 and increment (1+) while the condition in curly braces is true 1 2 4*x is a list of 1, 2, and 4 times the current value $ convert to string

{x@<x}' sort each

? unique

# count

1= equal to 1

~ not

2* multiply by 2

• Once a code golfer, always a code golfer... :P – Quintec Sep 8 '18 at 2:20
• It is not too surprising if you've heard of Cyclic Numbers before, though there was always the possibility that some smaller number could work using other (non-cyclic) permutations. – Jaap Scherphuis Sep 8 '18 at 6:38
• the smallest number that doubles when shuffled is 125874 .. same digits with cyclic number 142857. – TSLF Sep 8 '18 at 14:38

Okay, the official, non-brute force method, YAY!

UGH!

The first things I noticed were:

That since the number can be divided by 2, it is even, so the last digit is also even.

Also,

You can rearrange the digits 3 ways, by [the number, the number multiplied by 2, and the number divided by 2], so the number is at least 3 digits long

That doesn't tell us a lot. However, after a while, I found

that the number can't be 3 digits long.

since

the last number is even, and doubling an even number gets an even number. An even number halved is always a whole number [or integer]. So the third digit is the number you get when you divide directly, not the number from the indirect half, [i.e. If it's 2, 1*2=2 directly, but 6*2=12, and the digit is 'indirect'] So the digits are the original number, the doubled number, and the direct halved number. 0 never works then, because it results in 000, which has only 1 permutation

Cases:

000, 142, 412, 284, 824, 326, 236, 468, and 648. All of which don't fit.

Apparently, though, I didn't need most of that information.

Read the first one, and the bold text in the second last one.

I found that

we need 1, 2, 4, 8, and 2 odd numbers that aren't 1.

because

If we need an even number, we use

[continued]

[1 and 4] for 2, [2 and 8] for 4, [2 and 3] for 6, and [4 and 6] for 8. Also, 6 and 8 double to more than 10, so they round up, and we need an odd number. Any even number doubled gets each of the even numbers. 6 and 8 means 2 odd numbers, and the only way to not use 6 or 8 is to replace with an odd number.

[almost...]

So that's 6 digits. We can't use 1 as the first digit, as that will halve into a 5 digit number, not 6.

so let's try using

2 as the first digit.

Also,

what are the 2 odd numbers?

Well,

they can be 3 and 5, 3 and 7, or 5 and 7, or 3 and 9, or 5 and 9, or 7 and 9.

And wow,

No zeros or sixes, because 1248, and 2 odd numbers leave no room in a 6 digit number. And the only thing that halves into 3 is 6, but since 6 isn't there, neither is 3. 9 needs _8/2 from either 1, 5, or 7. But that doubled gets 36 or 37 for 1, and 156 or 157 for 7. 3 and 5 makes 3 odd numbers, or too many. With 5, halving gets 39, again having 3 odd numbers. So we can't use 9.

Therefore,

5 and 7 are the missing odd numbers, since 3 and 9 are not!

So the digits are

1,2,4,5,7, and 8!

2. So 1,4,5,7, and 8 are left. We could by now try all 120 possibilities. But let's use logic. We can't have 0, 3, 6, or 9 [interesting pattern].

This means

We can't have 15, 17, or 18 (doubles to 3). We have to have 5 (not 1, see left) in front of 7, because if not, it halves and gets 3. We have to have an even number (not 4, see later) in front of 8, because then it will halve and get 9. We also can't have 45, 47, or 48, because that doubles to 9. We can't have 81, 82, or 84, because that doubles to 6.

Also,

Since we're using 2 first, a 1 must have 4 after it, or 14. But then there's no number that can go after 4 since 1 and 2 are used. So, 14 is at the end [2___14]. We also have 5 in front of 7, or 57. 8 has to go in front of 5 or 7, but since it can't go in front of 7, it goes in front of 5. So it's 857, then

Put it all together, and the answer is

285714 FINALLY!!!!! This took 1110 hours, no kidding.

Note that

This is 2/7. [Technically 2/7 is the number repeated.] I wonder why...