Cut numbers in {1..9}
into 2 parts, and group them into two dec numbers, a and b, respectively.
Given k∈{2..9}
, and for different k, look for all possible pairs of a and b that meets the condition a*k == b
For every dec c
, c*k
can only be one digit longer or no longer than c
. Since the toal length of a and b (in dec) has to be 9, we can get know that b
has to be 5 digits long while a
has to be 4 digits long. This makes the code a lot simpler.
For every k
in {2..2..8}
, we have b.lastDigit % 2 == 0
. And for every k
in {3..3..9}
, we have b.allDigitSum % 3 == 0
. Now we have the following code for listing everything we need.