Let t ( n ) denote the number of positive divisors of n including 1 and n . Define s ( n ) = t ( 1 ) + t ( 2 ) + ⋯ + t ( n ) .
Let
A
denote the number of positive integers
n
≤
2
0
1
5
with
s
(
n
)
odd; and
let
B
denote the number of positive integers
n
≤
2
0
1
5
with
s
(
n
)
even.
Find ∣ A − B ∣ .
This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try
refreshing the page, (b) enabling javascript if it is disabled on your browser and,
finally, (c)
loading the
non-javascript version of this page
. We're sorry about the hassle.
Easy and nice! Did the same!
Lemma s ( n ) ≡ [ n ] ( m o d 2 )
Proof Consider the function, f ( n ) = [ n ] + ∑ k = 1 n t ( k ) .
I will prove by induction that f ( n ) is even.
Note that f ( 1 ) is even.
Suppose f ( n ) is even,say 2 k
Now, f ( n + 1 ) = f ( n ) + t ( n + 1 ) + [ n + 1 ] − [ n ]
If n + 1 is a square,then t ( n + 1 ) is odd,say 2 m + 1 and [ n + 1 ] = [ n ] + 1 .
So, f ( n + 1 ) = 2 ( k + m + 1 )
If n + 1 is not a square,then t ( n + 1 ) is even,say 2 p and [ n + 1 ] = [ n ] .
So, f ( n + 1 ) = 2 ( k + p ) .Hence,in both cases f ( n + 1 ) is even and the lemma is proved.
Solution to the main problem
Hence A = ( n s u c h t h a t [ n ] i s o d d , 1 ≤ n ≤ 2 0 1 5 ) and B = ( n s u c h t h a t [ n ] i s e v e n , 1 ≤ n ≤ 2 0 1 5 )
Note that 4 4 2 < 2 0 1 5 ≤ 4 5 2
Now, A = ( [ ( 2 k − 1 ) 2 , ( 2 k ) 2 − 1 ] , k = 1 , . . 2 2 )
So, ∣ A ∣ = ∑ k = 1 2 2 ( ( 2 k ) 2 − 1 − ( 2 k − 1 ) 2 + 1 ) = ∑ k = 1 2 2 ( 4 k − 1 ) = 9 9 0
So, ∣ B ∣ = 2 0 1 5 − 9 9 0 = 1 0 2 5 .
So, ∣ A − B ∣ = 3 5
I programmed the functions for t(n) and s(n) in Python, and used dynamic programming (http://en.m.wikipedia.org/wiki/Dynamic_programming) on t(n) so that I didn't have to calculate its value over and over again, and it also makes it so I have the computing capacity to calculate s(n). From there, I tested all values of s(n) between 1 and 2015 to see if they were odd or even to find A and B, then printed the absolute value of the difference between A and B.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
|
That program is still pretty slow though, so then I reprogrammed s(n) to use dynamic programming:
1 2 3 4 5 6 |
|
Problem Loading...
Note Loading...
Set Loading...
Any number N can be written as a product of primes and this is unique by the fundamental theorem of arithmetic.
So N= p1^a1.....pn^an. It follows that the number of distinct divisors of this number is (a1+1)(a2+1).....(an+1). Where the ai are powers of the primes.
Now note that this expression will change parity when N is a perfect square as otherwise, the number of divisors will be even. So s(n) changes its parity when N is a perfect square.
We note that s(1), s(2), s(3). Are odd but s(4),...s(8) are even. Now 44^2<2015 but 45^2 > 2015.
Repeating the pattern noticed above shows us that a= (2^2 -1^2 )+(4^2 - 3^2 )+...+(44^2 -43^2 ). This can easily be evaluated to give A=990.
Now b=2015-990= 1025. So |A-B|= 35