Problem 7 of the Canadian Mathematical Olympiad 1971

Let n be a five digit number (whose first digit is non-zero) and let m be the four digit number formed from n by deleting its middle digit. Determine all n such that n/m is an integer.

Solution by Steve Dinh, a.k.a. Vo Duc Dien (dedicated to Andy Yanowitz)

Let n = abcde where a, b, c, d and e are positive integers from 0 to 9 and a ≠ 0.

We then have m = abde and

n = 10000a + 1000b + 100c + 10d + e

m = 1000a + 100b + 10d + e

If n/m = k is an integer, we have

10000a + 1000b + 100c + 10d + e = 1000ak + 100bk + 10dk + ek (1)

Now assume k > 10 or k = 10 + p where p is a positive integer; (1) becomes

10000a + 1000b + 100c + 10d + e = 10000a + 1000b + 100d + 10e + 1000ap + 100bp + 10dp + ep (2)

Now let’s find the possible value for p. We have

p = (100c – 90d – 9e) / (1000a + 100b + 10d + e),

but since a ≠ 0 and b, c, d and e are all non-negative integers, the denominator is then ≥ 1000 and the numerator is less than 1000, so p < 1, and k > 10 is not possible.

Similarly, if k < 10, p = (90d + 9e – 100c) / (1000a + 100b + 10d + e).

With the same argument k < 10 is not a possibility. Therefore k = 10.

Substitute k = 10 into (1), we have 100c = 90d + 9e which requires product 9e to be a multiple of 10 which is not possible. This equation has the only solution c = d = e = 0. So n = ab000 where a and b are positive integers where 0 < a ≤ 9 and 0 ≤ b ≤ 9. So numbers n are

10000, 11000, 12000, 13000, 14000, 15000, 16000, 17000, 18000, 19000, 20000, 21000, 22000, 23000, 24000, 25000, 26000, 27000, 28000, 29000, 30000, 31000, 32000, 33000, 34000, 35000, 36000, 37000, 38000, 39000, 40000, 41000, 42000, 43000, 44000, 45000, 46000, 47000, 48000, 49000, 50000, 51000, 52000, 53000, 54000, 55000, 56000, 57000, 58000, 59000, 60000, 61000, 62000, 63000, 64000, 65000, 66000, 67000, 68000, 69000, 70000, 71000, 72000, 73000, 74000, 75000, 76000, 77000, 78000, 79000, 80000, 81000, 82000, 83000, 84000, 85000, 86000, 87000, 88000, 89000, 90000, 91000, 92000, 93000, 94000, 95000, 96000, 97000, 98000, 99000

a total of 90 numbers.

Following is a computer program by Andy Yanowitz to solve this problem:

int main (int argc, const char * argv[]) {

	unsigned int m;
	unsigned int c=0;

	for (unsigned int i = 10000; i<= 99999; i++)
	{
		unsigned int n = i;
		unsigned int tenThousands = n/10000;
		n -= tenThousands*10000;
		unsigned int thousands = n/1000;
		n -= thousands*1000;
		unsigned int hundreds = n/100;
		n -= hundreds*100;
		unsigned int tens = n/10;
		n -= tens*10;
		unsigned int ones = n;
		m = (tenThousands*1000) + (thousands*100) + (tens*10) + (ones);
		if ((i % m) == 0)
		{
			c += 1;
			printf("d\n",i,m);
		}
	}
	printf("total: %d\n",c);
	return 0;

}