Skip to content
Related Articles
Sum of cubes of even and odd natural numbers
• Last Updated : 09 Oct, 2018

We know that sum of cubes of first n natural numbers is = (n(n+1)/2)2.

Sum of cube of first n even natural numbers
23 + 43 + 63 + ……… + (2n)3

```Even Sum = 23 + 43 + 63 + .... + (2n)3
if we multiply by 23 then
= 23 x (13 + 23 + 32 + .... + (n)3)
= 23 + 43 + 63 + ......... + (2n)3
=  23 (n(n+1)/2)2
=  8(n(n+1))2/4
=  2(n(n+1))2
```

Example :

```Sum of cube of first 4 even numbers = 23 + 43 + 63 + 83
put n = 4     = 2(n(n+1))2
= 2*(4*(4+1))2
= 2(4*5)2
= 2(20)2
= 800
8 + 64 + 256 + 512 = 800
```

Program for Sum of cubes of first n even numbers

Sum of cube of first n odd natural numbers
We need to compute 13 + 33 + 53 + …. + (2n-1)3

```OddSum   = (Sum of cubes of all 2n numbers) - (Sum of cubes of first n even numbers)
=  (2n(2n+1)/2)2 - 2(n(n+1))2
=  n2(2n+1)2 - 2* n2(n+1)2
=  n2[(2n+1)2 - 2*(n+1)2]
=  n2[4n2 + 1 + 4n - 2n2 - 2 - 4n]
=  n2(2n2 - 1)
```

Example :

```Sum of cube of first 4 odd numbers = 13 + 33 + 53 + 73
put n = 4     = n2(2n2 - 1)
= 42(2*(4)2 - 1)
= 16(32-1)
=  496
1 + 27 + 125 + 343 = 496
```

Program for Sum of cubes of first n odd numbers

Attention reader! Don’t stop learning now. Get hold of all the important mathematical concepts for competitive programming with the Essential Maths for CP Course at a student-friendly price. To complete your preparation from learning a language to DS Algo and many more,  please refer Complete Interview Preparation Course.

My Personal Notes arrow_drop_up