[Home] [Puzzles & Projects] [Delphi Techniques] [Math topics] [Library] [Utilities]


Problem DescriptionA certain village was overrun with mice. In fact there were so many that they decided to bring in some cats to get rid of the mice. By a strange coincidence, each cat killed the same number of mice and each cat killed more mice than there were cats. Altogether they killed 10,001 mice. How many cats were there? Source: Math and Logic Puzzles for PC Enthusiasts, J. J. Clessa, Dover Books. Background & TechniquesWe need to find two numbers whose product is 10,001. Hopefully there is only one such pair or else we have more than one correct answer. We'll just loop through all possible divisors of 10,001 from 3 up to the square root of 10,001 looking for ones the divide 10,001 exactly  these are the factors of 10,001. We'll assume that the desired answer is not that one cat killed 10,001 mice. And 2 only divides even numbers, so we can start with 3. We can stop at sqrt(10001)  (sqrt is Delphi's square root function) because if any factor is larger than this, another factor must be smaller. Running/Exploring the Program
Suggestions for further explorationGeneralize the problem by taking the total of cats and mice as an input. 10,001 has only 2 factors, both prime numbers. Prime numbers are integers that have no integer divisors except 1 and themselves. This process of factoring numbers is important for lots of integer arithmetic problems. Modern encryption methods depend on the fact that very large numbers are difficult to factor, even by computer. Somebody, Euclid I think, proved that every integer can be factored into a product of primes in exactly one way (ignoring rearranging the factors). This is called the Fundamental Theorem of Arithmetic. There are lot's of neat things to do with primes and factoring as we'll see in the Prime Factors program where we'll be generating lots of primes. Check out Dr Math and The Prime Page sites for more interesting information. Try a search on "primes factoring" for many more pages.

[Feedback] [Newsletters (subscribe/view)] [About me]Copyright © 20002017, Gary Darby All rights reserved. 