Let M = sum of the cubes of the first 2024 odd numbers
and N = sum of the cubes of the first 2023 even numbers.
Find M-N
The sum of the first n cubes: 1^3 + 2^3 + ... n^3 = n^2(n+1)^2/4
To get the sum of the first n even cubes, just multiply by 8 = 2^3
2^3 + 4^3 + ... + (2n)^3 = 2*n^2(n+1)^2
To get the sum of the first n odd cubes start with the sum of all cubes from 1 to 2n and subtract off the evens.
(2n)^2((2n)+1)^2/4 - 2*n^2(n+1)^2
(4n^2)(4n^2 + 4n + 1)/4 - 2*n^2(n^2 + 2n + 1)
(4n^4 + 4n^3 + n^2) - (2n^4 + 4^3 + 2n^2)
2n^4 - n^2
n^2(2n^2 - 1) <-- sum of first n odd cubes
Let n = 2023
Sum of first (n+1) odd cubes minus first n even cubes:
(n+1)^2(2(n+1)^2 - 1) - 2*n^2(n+1)^2
(n+1)^2 * [(2(n+1)^2 - 1) - 2*n^2]
(n+1)^2 * (2n^2 + 4n + 1 - 2n^2)
(n+1)^2 * (4n + 1)
4n^3 + 9n^2 + 6n + 1
For n = 2023: 33153589568
------ verified with program -----
ans = 0
for n in range(1,4048):
ans += (-1)**(n+1) * n**3
print(ans)
Output: 33153589568
|
Posted by Larry
on 2023-11-03 10:19:07 |