Enigma 1535 — Back to front

by Bob Walker

There are two six digit numbers for which reversal of the digits delivers a multiple of the original number. Find the samller of the two — or even both of them!


Don’t miss the footnote.

      a b c d e f
                    x
      −−−−−−−−
      f e d c b a
     
     
      If x is even then a is even
     
      ax ≤ 9
      fx mod 10 = a
     
      If x ≥ 5 then
           a = 1
           xf ≤ 9
           fx mod 10 = 1
           x = 9 and f = 9 is the only candidate
     
      If x = 4 then
           a = 2
           ax = 8 ≤ f ≤ 9
           fx mod 10 = 2
           f = 8 is the only candidate
     
      If x = 3 then
           a = 1, 2 or 3
           If a = 1
                ax = 3 ≤ f ≤ 5
                fx mod 10 = 1
                there are no candidates for f
           If a = 2
                ax = 6 ≤ f ≤ 8
                fx mod 10 = 2
                there are no candidates for f
           If a = 3
                ax = 9 ≤ f ≤ 9
                fx mod 10 = 3
                there are no candidates for f
     
      If x = 2 then
           a = 2 or 4
           If a = 2
                ax = 4 ≤ f ≤ 5
                fx mod 10 = 2
                there are no candidates for f
           If a = 4
                ax = 8 ≤ f ≤ 9
                fx mod 10 = 4
                there are no candidates for f
     
Switch attention to 2nd and 5th digits
           call the carry digit from fx z.
           call the carry digit from eb y.
           fx = 10z + a
           y = fax
           e = bx − 10y + q where 0 ≤ q < x
           (ex + z) mod 10 = b
     
      If x = 9 and f = 9 and a = 1
           z = 8
           y = 0
           e = 9b + q
           b = 0 or 1
           If b = 0
                e = q = 0,1 ... 8
                e = 8 gives (ex + z) mod 10 = 0 = b *****
           If b = 1
                e = 9 gives (ex + z) mod 10 = 9 != 1
     
      If x = 4 and f = 8 and a = 2
           z = 3
           y = 0
           e = 4b + q where 0 ≤ q < 4
           b = (ex + z) mod 10 must be odd
           b = 1
           e = 4, 5, 6 or 7, but only 7 satisfies
                (ex + z) mod 10 = b
     
      Our smallest candidate is:
      a = 1 b = 0 e = 8 f = 9 x = 9
     
      1 0 c d 8 9
                     9
      −−−−−−−−
      9 8 d c 0 1
     
     
      9d + 8 = c + 10z
      9c + z = d + 10y
      y = 8
     
      9c + z = d + 80
      9d + 8 = c + 10z
     
      9c = 80 + d − z ≥ 72
      c = 8 or 9
     
      If c = 8
           d = 0 and z = 8
     
      If c = 9
           d − z = 1
           9d + 8 = 9 + 10d − 10
           d = 9
     
      1 0 9 9 8 9
                     9
      −−−−−−−−
      9 8 9 9 0 1
     
     
      Our other candidate is:
      a = 2 b = 1 e = 7 f = 8 x = 4
      2 1 c d 7 8
                     4
      −−−−−−−−
      8 7 d c 1 2
     
      4d + 3 = c + 10z
      4c + z = d + 10y
      4 + y = 7
     
      4c + z = d + 30
      4c = 30 + d − z ≥ 27
      c = 7, 8 or 9
     
      If c = 7
           z = d + 2
           4d + 3 = c + 10z = 7 + 10d + 20
           0 = 6d + 24 i.e. c != 7
     
      If c = 8
           z = d − 2
           4d + 3 = c + 10z = 8 + 10d − 20
           0 = 6d − 15 i.e. c != 8
     
      If c = 9
           z = d − 6
           4d + 3 = c + 10z = 9 + 10d − 60
           0 = 6d − 54
           c = 9 and d = 9
     
      2 1 9 9 7 8
                     4
      −−−−−−−−
      8 7 9 9 1 2
     
         // Confirmed by
         #include 
         #include 
         #include 
         
         main(int argc, char **argv)
         {  int n, prod, x;
            char nchars[10];
            char pchars[10];
            n = 1000000;
            while  ( --n >= 100000 )
            {  x = 1;
               sprintf(nchars, "%d", n);
               while  ( (prod = (++x)*n) < 1000000 )
               {  sprintf(pchars, "%d", prod);
                  if  ( nchars[0] == pchars[5]
                     && nchars[1] == pchars[4]
                     && nchars[2] == pchars[3]
                     && nchars[3] == pchars[2]
                     && nchars[4] == pchars[1]
                     && nchars[5] == pchars[0]
                      )
                     printf("%d times %s = %s\n", x, nchars, pchars);
               }
            }
         }

In fact, you can have a many nines in the middle as you like, and in both solutions the sums of corresponding digits in product and original number are the same.