Problem:
Every positive integer is either nice or naughty, and the Oracle of Numbers knows which are which. However, the Oracle will not directly tell you whether a number is nice or naughty. The only questions the Oracle will answer are questions of the form "What is the sum of all nice divisors of ?", where is a number of the questioner's choice. For instance, suppose (just for this example) that and are nice, while and are naughty. In that case, if you asked the Oracle, "What is the sum of all nice divisors of ?", the Oracle's answer would be .
Show that for any given positive integer less than million, you can determine whether is nice or naughty by asking the Oracle at most four questions.
Solution
Solution:
Let denote the sum of all nice divisors of . Note that , where denotes the sum of all the divisors of , including and .
We also note the following facts about the function:
1. is multiplicative: if and are relatively prime (share no prime factors), then .
2. If is prime, then .
To solve the problem, let us consider a few cases.
- Suppose is prime. Then ask the Oracle to compute . Clearly if and only if is nice.
- Suppose is a power of a prime, so for some prime , with . Again, ask the Oracle to compute . We claim again that if and only if is nice. Clearly if is nice, then . But if is naughty, then .
- Now suppose that has at least two prime factors, so we can write , where are the two smallest primes found in the factorization of , , and is an integer whose prime factorization does not contain or (of course, could equal ). Note that contains at most different primes, since the product of the first primes is larger than million. We will modify the previous strategy, where we examined a subset of the divisors of that were less than and whose sum was bounded below ; this allowed us to focus on and determine whether it is nice or naughty.
The subset of the divisors that we seek is the set of divisors of that are multiples of ; in other words, . We claim that the sum of the elements of is less than , and since , we conclude that is nice if and only if the sum of the nice members of is greater than or equal to (this follows because our claim implies that the members of that are not have a sum that is strictly less than ).
Two things remain: to verify the claim that the sum of all the members of is less than , and we need to know how to get the Oracle to compute the sum of the nice members of with at most four questions.
1. The sum of the members of is equal to . By fact #2 above,
where the range over the distinct prime factors of . We know that there are at most five such prime factors, and this product is bounded above by
which is clearly less than .
2. Finally, let the "universal set" be the divisors of , and let and denote the divisors of and , respectively. It is easy to see that is the complement of (since membership in guarantees that the exponent of is too small, and membership in does the same for ). By the inclusion-exclusion principle, the members of can be obtained by starting with the universal set (all divisors of ), removing members of , removing members of , and then adding back in the members of , which just consists of the divisors of . Consequently, the sum of the nice members of is given by
which requires just four questions to compute!