Generalizing multiplication by 9 pattern

17 Views Asked by At

Playing a little bit around with the multiplication by 9 (for learning purpose), I found that there is an interesting pattern.

I started with the common multiplications:

with 0 > 'a' < 11 and being the operand multiplied by 9 and 'o' being the output
decompose the number into digits da1, da2

do1 = n - 1
do2 = 10 - da1

Then I wanted to go further and include all other numbers and I got something like:

decompose the number into digits dn1, dn2, dn3 ...

do1 = a - `all digits of a's next tenth`
do2 = `a's previous tenth - abs(10 - a)`  

However, since I didn't study math and this method looks a little bit too wordy, I would like some help to, first review and find potential counterexample, and second to help me write a "formal" mathematical expression.

Examples

  • 8 * 9 => (8-1, 10 - 8) => (7, 2) => 72
  • 31 * 9 => (31 - 4, 30 - abs(10 - 31)) => (27, 9) => 279
  • 111 * 9 => (111 - 12, 110 - abs(10 - 111)) => (99, 9) => 999 the