Given that the sum of first n terms of
the series is #1^2+2.2^2+3^2+2.4^2+5^2+...
# is #n(n+1)^2 /2# when n is even
So when n is even
#S_n=1^2+2.2^2+3^2+2.4^2+5^2+...+(n-1)^2+
2 n^2 =n(n+1)^2 /2.....[1]#
when n is odd the n th term or last term is #n^2#
Now when n is odd #n-1# will be even. So putting #n-1# in place of n in relation [1] we get the sum up to #n-1# terms
Hence
#S_(n-1)=1^2+2.2^2+3^2+2.4^2+5^2+...+(n-2)^2+
2 (n-1)^2 =(n-1)(n-1+1)^2 /2#
# =((n-1)n^2) /2#
So when n is odd the sum up to n th term will be
#S_n=S_(n-1)+n^2=((n-1)n^2) /2+n^2=n^2((n-1)/2+1)#
#=(n^2(n+1))/2#