What is the largest value of the natural number n such that the sum 1 2 + 2 2 + … + n 2 is a perfect square ?
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.
Actually 2 4 is the only possible solution.
And , this is a problem of number theory
Log in to reply
1 is also a possible solution.
No it isn't! Check out my python code in the solution, there are other numbers as well.
There exists an "elementary number theory" proof to this result, which is quite convoluted. For more details, see American Mathmatical Monthly .
Well my code says 24 isn't the largest natural number satisfying the given condition. There are many other numbers besides 24.
Sum the series as (1/6)n(n+1)(2n+1)=m^2
The solutions are n=24 and m=70, which gives answer as 24.
I used the following python code. Also I used the while True loop which is an infinite loop so that I could find other possibilities besides 24
1 2 3 4 5 6 7 8 |
|
The answer in the question is wrong as 24 isn't the largest natural number such that the given sum is a perfect square
Output 24 2547750 2828093 3974004 4636697 5019548 5065968 5529976 6434771 6741437 7101496 7898119 8192485 9530917 9774922 9916100 10303942 10514246 10656671 11945152 12032855 12153127 12799512 12819261 13801485 15276205 15347381 15960792 16108784 16236906 16357744 16400624 16439442 16457969 16676437 16866476 17203662 17315619 17440708 17576703 17592831 17798035 17829491 17844733 17918157 18401354 18439817 18604362 18849433 18868909 18982624
You are getting multiple answers because of precision issues with your code. 1 and 12 are the only possible values. You can check this by printing your square roots and squaring them.
Log in to reply
Even I thought the same at first, I checked my code thrice and it's surprising to know that 24 isn't the largest natural number satisfying the condition. See my code, if you find any error tell me please.
Log in to reply
The sum for
n
=
2
5
4
7
7
5
0
is
5
5
1
2
5
1
0
5
2
6
0
9
3
5
8
0
8
7
5
which is not a perfect square. The square root is approximately
2
3
4
7
8
7
3
6
1
7
.
9
9
8
5
4
5
6
. Your code is rounding off the value of square root which is causing the error. As I said, you can use a
print(math.sqrt(s))
in your loop to check the same.
Log in to reply
@Ankush Tiwari – Yeah I did that and for n=2547750, the square root it gave is 2347873618. How did you get it in floating point? Did you use coding because I don't think a manual calculator can solve this??
Log in to reply
@Nashita Rahman – Yes, I used a seperate python code to find square root of 5 5 1 2 5 1 0 5 2 6 0 9 3 5 8 0 8 7 5 .
Log in to reply
@Ankush Tiwari – But how ? I can't really understand where am I going wrong, my code is alright!
Log in to reply
@Nashita Rahman
–
The problem is that
math.sqrt()
does not give precise value of square root. Instead you can use this code which does not depend on precision of
math.sqrt
.
import math
s = 0
i = 1
while True:
s = s + i*i
a = int(math.sqrt(s))
if a*a == s:
print(i)
i = i + 1
Log in to reply
@Ankush Tiwari – Why are you taking a to be an integer? The square root maybe float!
Log in to reply
@Nashita Rahman – because a will be an integer if s is a perfect square. If s is not a perfect square, then a will be rounded to nearest integer and if condition will be false, so it doesn't matter.
Log in to reply
@Ankush Tiwari – Not necessary a will be a perfect square when it is an integer!
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
|
OUTPUT
1
24
24 isn't the largest natural number!!! My python code gave other numbers besides 24, check out the solution. There are other possibilities, try running an infinite loop you will get other possibilities besides 24.
Log in to reply
Actually no. My code also gave something like that.. 24 is the greatest... Can be proved with Number theory and my code gave some different and wrong values as I didn't took long long int somewhere... I guess. Similar problems might be there in ur program.
Log in to reply
24 isn't the greatest. You can check with the number 2547750 . Put it in the range of your code and see the result!!!
Log in to reply
@Nashita Rahman – C++ isnt capable of calculating more than what i did.. Python is a good calculator... so ... :) ... Idk.. but it didnt gave anything else... other than 1 and 24.
Heyyy! Where are you??? How was your JEE in April??
Log in to reply
@Nashita Rahman – Lets see.... :D .... Idk.. let the result come out... Even idk about the marks i will be scoring accrdng to Resonance answer keys as response sheet is not out... Lets wait... what else can we do :( ....
Log in to reply
@Md Zuhair – Good luck with the results :) I am sure you'll do well!
Log in to reply
@Nashita Rahman – dont be so sure ;)
Log in to reply
@Md Zuhair – I am 110% sure :P
Log in to reply
@Nashita Rahman – byas... ebar hoye gelo gorbor
Log in to reply
@Md Zuhair – gorbor keno hobe? Brilliant students der results e kono dino gorbor hoena :P
Log in to reply
@Nashita Rahman – orom mone hoy...
Log in to reply
@Md Zuhair – The answer key has been released?? How much are you getting?
Log in to reply
@Nashita Rahman – 262 asche...
Log in to reply
@Md Zuhair – WOW!! Last time your percentile was 99.508, I think this time it will be more, congratulations!!
Log in to reply
@Nashita Rahman – Ekhono don't deduce anything. It's still a long way
Log in to reply
@Md Zuhair – Okaaaaaaaay! Btw I have a doubt in coding, help me please.While concatenating two strings, when I am giving a sentence as input in first string and for input in second string, it's not being concatenated. But the program is working for words. In short, I can't concatenate two sentences. I am doing it in C programming not Python.
Log in to reply
@Nashita Rahman – Is it because while concatenating, the program is reading the spaces as termination? But spaces don't imply '\0' ??? I mean space is not null, right??
Log in to reply
@Nashita Rahman – Did u used fflush(stdin) ? (I use this in c++) u can search for d substitute in google
Log in to reply
@Md Zuhair – Nope I didn't. Anyway, thank you.
@Nashita Rahman – More over final answer keys are not out... It's just tentative. Wait... My score might decrease
Log in to reply
@Md Zuhair – Best of luck with the final answer key!
Problem Loading...
Note Loading...
Set Loading...
After struggling to solve this problem with pen and paper, I eventually resorted to writing a Python programme to "spoon-feed" me the answer. Since this question does not fall into any distinct category, I would presume that programming solutions are allowed.
Here's my the Python programme:
The programme outputs 24 as the answer.