**From New Scientist #1618, 23rd June 1988** [link]

I have before me a machine which operates on integers. Turning the handle once takes the integer at the input, adds 1 to it and then divides the result by 2, providing only that this is possible without fractional result or remainder. The result is displayed at the output and automatically fed back into the input. If turning the handle would otherwise have produced a fractional result or a remainder, the handle of the machine refuses to turn.

I fed an integer *N* into the input. I turned the handle and found that the ultimate digit of the number output was the same as the ultimate digit of the number input. Intrigued, I turned the handle again and again. All in all I turned the handle 11 times until the ultimate digit of the 11th number output was no longer the same as the ultimate digit of *N*.

I cleared the machine and fed an integer *A* into the input. I turned the handle and found that the ultimate digit of the number output was not the same as the ultimate digit of the input number *A*. Put out, I turned the handle again and again. All in all I turned the handle 11 times. The ultimate digit of the 11th number output was one less than the ultimate digit of the penultimate number output.

What was the smallest possible value of: (a) *N*?; (b) *A*?

[enigma467]

### Like this:

Like Loading...

For this puzzle I took the use of “integer” to mean “positive integer” (i.e. 1, 2, 3, 4, …).

This Python program runs in 100ms.

Run:[ @repl.it ]Solution:The smallest positive integers are: (a) 10241; (b) 2049.For (a), the repeated applications give:

Each application gives a number ending in the digit 1, until the 11th application gives a number ending in 6, and there can be no further applications (as 6 is even).

Each of the first 10 numbers is of the form

(2^k)×10 + 1.For (b), the repeated applications give:

Each application gives a number whose final digit is different from that of the input number. The 11th application gives the number 2, and there can be no further applications (as 2 is even).

Each of the first 10 numbers is of the form

(2^k) + 1If we allow negative integers we find there are solutions such as

n = –10239for part (a), which is generally considered to be “smaller than” 10241 (if we take “smaller” to mean “more negative”, or if we compare magnitudes), similarly for part (b), there isn = –2047. And if we are using “more negative” there are further values that are more negative than these.