Cmimc 2017 NT
Cmimc 2017 NT
3. For how many triples of positive integers (a, b, c) with 1 ≤ a, b, c ≤ 5 is the quantity
(a + b)(a + c)(b + c)
not divisible by 4?
4. Let a1 , a2 , a3 , a4 , a5 be positive integers such that a1 , a2 , a3 and a3 , a4 , a5 are both geometric sequences and
a1 , a3 , a5 is an arithmetic sequence. If a3 = 1575, find all possible values of |a4 − a2 |.
5. One can define the greatest common divisor of two positive rational numbers as follows: for a, b, c, and d
positive integers with gcd(a, b) = gcd(c, d) = 1, write
a c gcd(ad, bc)
gcd , = .
b d bd
For all positive integers K, let f (K) denote the number of ordered pairs of positive rational numbers (m, n)
wiht m < 1 and n < 1 such that
1
gcd(m, n) = .
K
What is f (2017) − f (2016)?
6. Find the largest positive integer N satisfying the following properties:
• N is divisible by 7;
• Swapping the ith and j th digits of N (for any i and j with i 6= j) gives an integer which is not divisible
by 7.
7. The arithmetic derivative D(n) of a positive integer n is defined via the following rules:
• D(1) = 0;
• D(p) = 1 for all primes p;
• D(ab) = D(a)b + aD(b) for all positive integers a and b.
Find the sum of all positive integers n below 1000 satisfying D(n) = n.
8. Let N be the number of ordered triples (a, b, c) ∈ {1, . . . , 2016}3 such that a2 + b2 + c2 ≡ 0 (mod 2017). What
are the last three digits of N ?
9. Find the smallest prime p for which there exist positive integers a, b such that
a2 + p3 = b4 .
g(n) = gcd {0!n!, 1!(n − 1)!, 2(n − 2)!, . . . , k!(n − k)!, . . . , n!0!} .
1 |00 {z
. . . 0} 1 |00 {z
. . . 0} 1.
100 zeros 100 zeros
3. Say an integer polynomial is primitive if the greatest common divisor of its coefficients is 1. For example,
2x2 + 3x + 6 is primitive because gcd(2, 3, 6) = 1. Let f (x) = a2 x2 + a1 x + a0 and g(x) = b2 x2 + b1 x + b0 ,
with ai , bi ∈ {1, 2, 3, 4, 5} for i = 0, 1, 2. If N is the number of pairs of polynomials (f (x), g(x)) such that
h(x) = f (x)g(x) is primitive, find the last three digits of N .
Number Theory Solutions Packet
1. There exist two distinct positive integers, both of which are divisors of 1010 , with sum equal to 157. What
are they?
Solution. Suppose 157 = x + y for x and y divisors of 1010 . Note that one of x or y must be odd and hence
a power of 5. Similarly, one of x or y must be not divisible by 5, and hence a power of 2. Thus 157 = 2a + 5b
for some nonnegative integers a and b. Now the largest power of 5 smaller than 157 is 125, and testing a
few cases we indeed find that 157 − 125 = 32 is the only solution which works. Thus the two integers are
125 and 32 .
2. Determine all possible values of m + n, where m and n are positive integers satisfying
Solution. Recall that by definition the least common multiple of two numbers is a multiple of their gcd.
Let lcm(m, n) = k · gcd(m, n) for some positive integer k. Then
Recall that 103 is prime, so either gcd(m, n) = 103 and k = 2 or gcd(m, n) = 1 and k = 104. In the former
case, let m = 103m0 and n = 103n0 . Then
so lcm(m0 , n0 ) = 2. Combining this with the fact that m 6= n means that m0 and n0 must be 1 and 2 in some
order, i.e. {m, n} = {103, 206}. In the latter case, write 104 = 23 · 13. Since gcd(m, n) = 1, it follows that m
and n must either be 1 and 104 or 8 and 13 in some order. Combining both of these cases yields that m + n
must be either 21, 105, or 309 .
3. For how many triples of positive integers (a, b, c) with 1 ≤ a, b, c ≤ 5 is the quantity
(a + b)(a + c)(b + c)
not divisible by 4?
Solution. Note that since the sum of the three multiplicands is (a + b) + (b + c) + (c + a) = 2(a + b + c), we
know that at least one of a + b, b + c, or c + a is even. Thus the product is always divisible by 2. In order for
the product to not be divisible by 4, it must be the case that two of these quantities are odd and the third
one is congruent to 2 modulo 4.
WLOG suppose that a + b and a + c are odd and b + c ≡ 2 (mod 4). Since (a + b) − (a + c) = b − c is even, it
follows that b and c are of the same parity. We now split into cases based on whether both are even or both
are odd.
• If both are even, then they cannot both be congruent modulo 4, or else their sum would be divisible by
4. It follows that b and c must be 4 and 2 in some order. Then a can be 1, 3, or 5; this gives a total of
2 × 3 = 6 possibilities in this case.
• If both are odd, then they both must be congruent modulo 4, or else their sum would be 1 + 3 ≡ 0
(mod 4). This means they must be both either 1 (mod 4) or 3 (mod 4). Then a can be either 2 or 4, so
there are a total of 2 × (22 + 1) = 10 possibilities in this case.
Multiplying by 3 from our WLOG above gives the final answer as 3(6 + 10) = 48 .
4. Let a1 , a2 , a3 , a4 , a5 be positive integers such that a1 , a2 , a3 and a3 , a4 , a5 are both geometric sequences and
a1 , a3 , a5 is an arithmetic sequence. If a3 = 1575, find all possible values of |a4 − a2 |.
where m/n and p/q are reduced fractions and a = 1575. Then arithmetic sequence gives
m2 q 2 + n2 p2 = 2n2 q 2 .
Since m and n are coprime, it follows that q | n. Similarly, n | q and hence n = q. We can rewrite
m2 + p2 = 2n2 .
Because each term is an integer, we also have n2 | a, and hence n = 1, 3, 5, 15, since 1575 = 32 · 52 · 7. Assume
that m ≤ p; then the only triples (m, p, n) that satisfy these conditions are
(m, p, n) = (1, 1, 1), (3, 3, 3), (5, 5, 5), (15, 15, 15), (1, 7, 5), (3, 21, 15).
The possible ratios (m/n, p/n) are hence (1, 1) and (1/5, 7/5), and so
p
m 6
a4 − a2 = a − ∈ 0 · 1575, · 1575 = {0, 1890} .
n n 5
5. One can define the greatest common divisor of two positive rational numbers as follows: for a, b, c, and d
positive integers with gcd(a, b) = gcd(c, d) = 1, write
a c gcd(ad, bc)
gcd , = .
b d bd
For all positive integers K, let f (K) denote the number of ordered pairs of positive rational numbers (m, n)
wiht m < 1 and n < 1 such that
1
gcd(m, n) = .
K
What is f (2017) − f (2016)?
Solution. First remark that the gcd condition can be dropped, since if c and d are scaled up by a factor
of k, both gcd(ad, bc) and bd are scaled up by k, and so their effects cancel out.
Note that
e a c e gcd(ad, bc) gcd(ead, ebc) ae ce
gcd , = · = = gcd , .
f b d f bd bdf bf df
Hence this definition of gcd is in fact multiplicative, and so it suffices to find pairs of rational numbers m0 and
n0 such that gcd(m0 , n0 ) = 1.
a0 c0
Write m0 = b0 and n0 = d0 . Then
a 0 c0
gcd , =1 ⇐⇒ gcd(a0 d0 , b0 c0 ) = b0 d0 .
b0 d0
a0
Let a0 d0 = M b0 d0 and b0 c0 = N b0 d0 for some integers M and N with gcd(M, N ) = 1. This simplifies to b0 =M
0
and dc0 = N . So in fact, m0 and n0 are actually relatively prime integers.
Hence f (K) is equal to the number of pairs of positive integers (M, N ) with 1 ≤ M < K and 1 ≤ N < K such
that gcd(M, N ) = 1. This in turn means that f (2017) − f (2016) equals the number of such pairs with either
M = 2016 or N = 2016. If M = 2016, then N can be any one of the integers for which gcd(N, 2016) = 1,
of which there are ϕ(2016) of them. Similarly, N = 2016 yields ϕ(2016) more ordered pairs. There is no
possibility for overcounting, and so the final answer is
2ϕ(2016) = 1152 .
• N is divisible by 7;
• Swapping the ith and j th digits of N (for any i and j with i 6= j) gives an integer which is not divisible
by 7.
Solution. Write
k
X
N = ak ak−1 · · · a1 a0 = 10m am .
m=0
Suppose digits ai and aj are swapped, whgere 0 ≤ i < j ≤ k, to form a new integer N 0 . Then it is not hard
to see that
N − N 0 = 10j aj + 10i ai − 10j ai + 10i aj = 10j − 10i (aj − ai ).
The condition given in the problem statement is thus equivalent to this difference not being divisible by 7 for
all i and j.
If aj − ai is divisible by 7, then ai ≡ aj (mod 7). This in turn means that all digits must have different
residues modulo 7.
If 10j − 10i is divisible by 7, then 10j−i ≡ 1 (mod 7). Remark that ord7 (10) = 6, meaning that it must be
the case that j − i ≡ 0 (mod 6). This means that any such N must have at most 6 digits; if this were not the
case, then swapping a0 and a6 would produce a new integer divisible by 7, thus violating the given conditions.
In all other cases, the difference will not be divisible by 7. Hence it suffices to find the largest integer N with
at most six digits such that N ≡ 0 (mod 7) and that each of the digits of N has a different remainder when
divided by 7. With this im mind, suppose k = 5, and write
5
X
N≡ 10m am ≡ 5a5 + 4a4 + 6a3 + 2a2 + 3a1 + a0 (mod 7).
m=0
In the interest of being greedy, set a5 = 9, a4 = 8, and a3 = 7; note that conveniently 987 is divisible by 7, so
the search for possible N is reduces to finding a0 , a1 , a2 ∈ {3, 4, 5, 6} such that
Note that by the Rearrangement Inequality 2a2 + 3a1 + a0 must be at least 2 · 4 + 3 · 3 + 5 = 22 and at most
2 · 5 + 3 · 6 + 4 = 32. Hence in fact it must be true that
The only solutions to this under the given constraints is (a2 , a1 , a0 ) = (3, 6, 4) and (a2 , a1 , a0 ) = (5, 4, 6), so
the largest N must be 987546 .
7. The arithmetic derivative D(n) of a positive integer n is defined via the following rules:
• D(1) = 0;
• D(p) = 1 for all primes p;
• D(ab) = D(a)b + aD(b) for all positive integers a and b.
Find the sum of all positive integers n below 1000 satisfying D(n) = n.
Solution. Let N be a positive integer such that D(N ) = N . Recall that we can write
N = pa1 1 · · · pakk
for some sequence of primes {pj }kj=1 and exponents {aj }kj=1 . We now prove a lemma which explains how to
compute arbitrary arithmetic derivatives.
LEMMA: We have
a1 ak
D (pa1 1 · · · pakk ) = pa1 1 · · · pakk + ··· + .
p1 pk
Proof. We first show that D(pj ) = jpj−1 for p a prime; this proves the claim in the case of j = 1. Fortunately,
this is not hard. Write
D(pj ) = pj−1 D(p) + pD(pj−1 ) = pj−1 + pD(pj−1 ).
Now the claim follows from a simple induction argument.
To prove the lemma, we induct on k. The base case of k = 1 follows from the above paragraph. Now assume
the inductive hypothesis holds for some k, and write
ak−1 ak−1
D (pa1 1 · · · pakk ) = pa1 1 · · · pk−1 D (pakk ) + pakk D pa1 1 · · · pk−1
a1 ak−1 ak −1
ak a1 ak−1 a1 ak−1
= p1 · · · pk−1 ak pk + pk p1 · · · pk−1 + ··· +
p1 pk−1
a1 ak
= pa1 1 · · · pakk + ··· + .
p1 pk
Going back to the original problem, note that D(N ) = N implies that
ak a1 ak a1 ak
a1
p1 · · · pk + ··· + = pa1 1 · · · pakk =⇒ + ··· + = 1.
p1 pk p1 pk
a1 p2 · · · pk ≡ 0 (mod p1 ).
Solution. We first claim that there are 20172 solutions if we allow a, b, c to equal 0. Letting z be such
2
that z ≡ −1 (mod 2017) (which we know exists because 2017 is a prime congruent to 1 (mod 4)), the given
congruence is equivalent to
If cz − b ≡ 0, then there is one choice for a and 2017 choices for b from which c is uniquely determined.
Otherwise, we have 2016 choices for the value of cz − b and 2017 choices for the value of a from which the
values cz + b, b, c are determined. Thus, overall there are 20172 triples (a, b, c) ∈ {0, . . . , 2016}3 satisfying the
condition.
We now use inclusion-exclusion to get the desired count. There are 2 · 2017 − 1 triples where a = 0, as all
choices for b except 0 yield two choices for c. The same is true for triples where b = 0, c = 0. This leads to a
count of 20172 − 6 · 2017 + 3, while the triple (0, 0, 0) has been added once and removed thrice from the count,
so we add 2 to get
N = 20172 − 6 · 2017 + 5 = (2017 − 5)(2017 − 1),
and the last three digits of N are 2012 · 2016 ≡ 192 (mod 1000).
9. Find the smallest prime p for which there exist positive integers a, b such that
a2 + p3 = b4 .
Solution. We rewrite the equation as p3 = (b2 − a)(b2 + a), and as b2 + a > b2 − a we have two cases.
• b2 + a = p2 , b2 − a = p: In this case, 2b2 = p(p + 1), and noting that p 6= 2 we have b2 = p( p+1
2 ), from
which we find p|b. However, then the right hand side must have at least two factors of p, while p| p+1
2 is
impossible. Thus there are no solutions in this case.
• b2 + a = p3 , b2 − a = 1: In this case, 2b2 = (p + 1)(p2 − p + 1), and we note again that p 6= 2. Now,
b2 = ( p+1 2
2 )(p − p + 1), and we have
gcd( p+1 2 2
2 , p − p + 1) = gcd(p + 1, p − p + 1) = gcd(p + 1, 3).
g(n) = gcd {0!n!, 1!(n − 1)!, 2(n − 2)!, . . . , k!(n − k)!, . . . , n!0!} .
Find the sum of all n ≤ 25 for which g(n) = g(n + 1).
n
νp (g(n)) = min νp (n!) − νp
1≤k≤n k
n
= νp (n!) − max νp ,
1≤k≤n k
and so
n n+1 n+1
(n + 1) = (k + 1) = (n − k + 1) ,
k k+1 k
while evidently
X `
n n k n−k
νp = − −
k s=1
ps ps ps
≤ `,
(n + 1)! (n + 2)!
= ,
lcm(1, . . . , n + 1) lcm(1, . . . , n + 2)
we have n + 2 = lcm(m,n+2)
m , where m = lcm(1, . . . , n + 1). Thus, n + 2 is relatively prime to 1, . . . , n + 1 and
is prime. The other direction is clear.
Thus, the desired n ≤ 25 are 1, 3, 5, 9, 11, 15, 17, 21 and their sum is 82 .
Individual Finals
1. Let τ (n) denote the number of positive integer divisors of n. For example, τ (4) = 3. Find the sum of all
positive integers n such that 2τ (n) = n.
1 00 . . . 0} 1 00
| {z . . . 0} 1.
| {z
100 zeroes 100 zeroes
Solution. Let N = 10202 + 10101 + 1, and let ω be a root of x2 + x + 1. Then since ω n = ω n mod 3 , we have
gcd(303, p − 1) ≤ 3 for each of these p. Thus, it suffices to show that 103 6≡ 1 (mod p) for any of these p; but
this is already obvious since 103 − 1 = 33 · 37. Thus the requested answer is 111 .
3. Say an integer polynomial is primitive if the greatest common divisor of its coefficients is 1. For example,
2x2 + 3x + 6 is primitive because gcd(2, 3, 6) = 1. Let f (x) = a2 x2 + a1 x + a0 and g(x) = b2 x2 + b1 x + b0 ,
with ai , bi ∈ {1, 2, 3, 4, 5} for i = 0, 1, 2. If N is the number of pairs of polynomials (f (x), g(x)) such that
h(x) = f (x)g(x) is primitive, find the last three digits of N .
Solution. We claim that h(x) = f (x)g(x) is primitive if and only if f (x), g(x) are primitive. We prove both
directions via contrapositive. If either f (x) or g(x) is not primitive, then some prime p divides all of its co-
efficients, and this p will also divide all of the coefficients of h(x). Thus, h(x) primitive ⇒ f (x), g(x) primitive.
Now, if h is not primitive, then some prime p divides all of its coefficients. Suppose for the sake of contradic-
tion that some coefficients of f, g are not divisible by p, and say ai , bj are those with minimal index. Then,
a0 , . . . , ai−1 , b0 , . . . bj−1 are all divisible by p. In h, the coefficient of the xi+j term is divisible by p and consists
of terms of the form ai−k , bj=k , ai+k bj−k for appropriately chosen values of k. However, these are all divisible
by p except ai , bj , and so the coefficient of xi+j is not divisible by p, a contradiction. Therefore, f (x), g(x)
are also not primitive, and f (x), g(x) primitive ⇒ h(x) primitive.
Now, f and g are determined by their coefficients, so it suffices to determine the number of triples of integers
(a, b, c) ∈ {1, 2, 3, 4, 5}3 satisfying gcd(a, b, c) = 1, as this determines the number of possible choices for f, g.
Noting that gcd(a, b, c) = gcd(gcd(a, b), c), we calculate
X X X
1= µ(d)
1≤a,b,c≤5 1≤a,b,c≤5 d| gcd(gcd(a,b),c)
gcd(a,b,c)=1
X X
= µ(d)
1≤a,b,c≤5 d| gcd(a,b)
d|c
X X 5
= µ(d) d
1≤a,b≤5 d| gcd(a,b)
X 5 3
= µ(d) d .
1≤d≤5
A simple calculation verifies that therefore the number of triples satisfying the desired conditions is 125 − 8 −
1 − 0 − 1 = 115. Therefore, the number of desired pairs of polynomials is 1152 ≡ 225 (mod 1000).
Remark. The fact that f (x), g(x) primitive ⇔ f (x)g(x) primitive is known as Gauss’ Lemma and has
numerous applications. For example, it is used to prove that an integer polynomial which is irreducible over
the rationals must be irreducible over the integers as well.