01 August 2022

More funny numbers - permutable and reversible

Permuted multiples

Write a script to find the smallest integer x such that x, 2x, 3x, 4x, 5x and 6x are permuted 
multiples of each other. For example, the integers 125874 and 251748 are permuted multiples of each other.

My immediate thought was that the answer is 142857, which I imagine most of us recognise as the repeating decimal sequence in 1/7 (and 2/7, 3/7 ... 6/7). So I could take a punt on a valid solution being:

say 142857;

But is there a smaller answer?  I spent some time thinking whether I could prove that there isn't, but failed. So I wrote a short script to test it, and indeed that is the right answer. 

I also ran the script up to a million and didn't find another answer, so perhaps it is unique?

Reversible numbers

We are looking for a number written as AB such that AB + BA has only odd digits.

The sum is clearly 10A + B + 10B + A, which is 11 (A + B).  

Clearly no single digit number will qualify, so all we need to do is look from 10 to 99 checking that 11 (A + B) doesn't contain [02468].  Three lines of code does it plus another two to present the output a la Mohammad.


No comments:

Post a Comment