Ok I figured out a nice pattern and after much blood, sweat and tears, I finally solved it. There will be 3 cases to consider.
Are you familiar with modulo arithmetic?
For m(mod 3)=0, that is, m=3,6,9,12...
We have the pattern:
m=3 , P = (3) + (0)
m=6 , P = (3+5+7) + (5)
m=9 , P = (3+5+7+9+11) + (5+9)
m=12, P = (3+5+7+9+11+13+15) + (5+9+13)
etc.
Now since in this case we don't need to consider what is happening in the other cases and we are dealing with m that are multiples of 3, let's take \frac{m}{3}=x. So for m=12, x=4 and you can consider that as being the 4th sequence in this lone pattern.
for x=1, we have 1 in the first bracket, and 0 in the second
for x=2, we have 3 in the first bracket, and 1 in the second
for x=3, we have 5 in the first bracket, and 2 in the second
for x=2, we have 7 in the first bracket, and 3 in the second
Can you see the pattern arising?
for x=x, we have (2x-1) in the first bracket, and (x-1) in the second
Now looking at the formulae I gave you earlier,
<br />
3+5+7+...+(2n+1)=n(n+2)<br />
and
<br />
5+9+13+...+(4n+1)=n(2n+3)<br />
Let the first bracket with the first formula be n=2x-1. What this means is we have to substitute n=2x-1 into the sum formula n(n-2).
Secondly, substitute n=x-1 in the second formula.
So we obtain P=(2x-1)(2x+1)+(x-1)(2x+1)=(3x-2)(2x+1)
That's the formula for m(mod 3)=0 where m/3=x.
So let's take m=12, thus x=4.
m=12, P=3+5+5+7+9+9+11+13+13+15=90
P=(3.4-2)(2.4+1)=10.9=90
It works for all others too
Now maybe you can try apply this idea to the other two cases? Let m(mod 3)=1, i.e. m=4,7,10... and \frac{m-1}{3}=x.
For m(mod 3)=2 let \frac{m+1}{3}=x
This will finally satisfy all your summations.