For positive integers n, let τ(n) denote the number of positive integer divisors of n, including 1 and n. For example, τ(1)=1 and τ(6)=4. Define S(n) by S(n)=τ(1)+τ(2)+⋯+τ(n). Let a denote the number of positive integers n≤2005 with S(n) odd, and let b denote the number of positive integers n≤2005 with S(n) even. Find ∣a−b∣.
解析
Solution 1
It is well-known that τ(n) is odd if and only if n is a perfect square. (Otherwise, we can group divisors into pairs whose product is n.) Thus, S(n) is odd if and only if there are an odd number of perfect squares less than n. So S(1),S(2) and S(3) are odd, while S(4),S(5),…,S(8) are even, and S(9),…,S(15) are odd, and so on.
So, for a given n, if we choose the positive integer m such that m2≤n<(m+1)2 we see that S(n) has the same parity as m.
It follows that the numbers between 12 and 22, between 32 and 42, and so on, all the way up to the numbers between 432 and 442=1936 have S(n) odd. These are the only such numbers less than 2005 (because 452=2025>2005).
Solution 2
Notice that the difference between consecutive squares are consecutively increasing odd numbers. Thus, there are 3 numbers between 1 (inclusive) and 4 (exclusive), 5 numbers between 4 and 9, and so on. The number of numbers from n2 to (n+1)2 is (n+1−n)(n+1+n)=2n+1. Whenever the lowest square beneath a number is odd, the parity will be odd, and the same for even. Thus, a=[2(1)+1]+[2(3)+1]…[2(43)+1]=3+7+11…87. b=[2(2)+1]+[2(4)+1]…[2(42)+1]+70=5+9…85+70, the 70 accounting for the difference between 2005 and 442=1936, inclusive. Notice that if we align the two and subtract, we get that each difference is equal to 2. Thus, the solution is ∣a−b∣=∣b−a∣=∣2⋅21+70−87∣=025.
Solution 3
Similarly, b=(32−22)+(52−42)+…+(452−442)−19, where the −19 accounts for those numbers between 2005 and 2024.
Thus a=(22−12)+(42−32)+…+(442−432).
Then, ∣a−b∣=∣2(22+42+…+442)−2(12+32+52+…432)+12−452+19∣. We can apply the formula 12+22+…+n2=6n(n+1)(2n+1). From this formula, it follows that 22+42+…+(2n)2=32n(n+1)(2n+1) and so that