find the sum of all the odd numbers which are perfect squares between 50 and 10000
Answers
Answer:
Step-by-step explanation:
The smallest odd square between 50 and 10000 is 81, 92. The biggest is 9801, 992. So the sum of all odd numbers between 50 and 10k would be
92+112+132+152+172+192+...+972+992
It’s useful to note that the x-th odd number is (2x−1). 9 is the 5th odd number, and 99, the 50th. So if we write the series as a summation:
∑50i=5(2i−1)2
To solve this, let’s create a general formula that computes the sum of the first n odd squares. That is, a formula which given n, returns 12+32+52+...+(2n−1)2.
Why is that useful? Well, we could find the sum of the first 50 odd squares, then subtract the sum of the first 4 squares in order to get the wanted sum. 4 not 5, as we need to count the fifth odd square too.
We could write this general formula as:
∑ni=1(2i−1)2
Expand the squared binomial:
∑ni=1(4i2−4i+1)
You can distribute this sum into three different sums:
∑ni=14i2−∑ni=14i+∑ni=11
We have three terms, which we can start breaking down.
Term 1: ∑ni=14i2 This sum is basically 4 times the sum of the first n squares. I’m not going into how this works, but it’s worth noting that the sum of the first n squares isn(n+1)(2n+1)6. So, this term equals 4n(n+1)(2n+1)6, or 2n(n+1)(2n+1)3.
Term 2: ∑ni=14i This is 4 times the sum of the first n natural numbers. That’s 4(n(n+1)2)or 2n(n+1).
Term 3: ∑ni=11 This is just n.
So, this sum evaluates to:
2n(n+1)(2n+1)3−2n(n+1)+n
Work that out and you’ll derive 4n3−n3.
Plugging in the numbers, our answer is
4(50)3−503−4(4)3−43=166566
That's our answer! The sum of all odd perfect squares between 50 and 10000 is 166,566.
Here's a Python program:
s = 0
for i in range(5, 51):
s += ((2*i)-1)**2
print(s)
>>> 166566
Hope it helps!