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**

2^{3} + 4^{3} + 6^{3} + ……… + (2n)^{3}

Even Sum = 2^{3}+ 4^{3}+ 6^{3}+ .... + (2n)^{3}if we multiply by 2^{3}then = 2^{3}x (1^{3}+ 2^{3}+ 3^{2}+ .... + (n)^{3}) = 2^{3}+ 4^{3}+ 6^{3}+ ......... + (2n)^{3}= 2^{3}(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 = 2^{3}+ 4^{3}+ 6^{3}+ 8^{3}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 1^{3} + 3^{3} + 5^{3} + …. + (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}= n^{2}(2n+1)^{2}- 2* n^{2}(n+1)^{2}= n^{2}[(2n+1)^{2}- 2*(n+1)^{2}] = n^{2}[4n^{2}+ 1 + 4n - 2n^{2}- 2 - 4n] = n^{2}(2n^{2}- 1)

**Example :**

Sum of cube of first 4 odd numbers = 1^{3}+ 3^{3}+ 5^{3}+ 7^{3}put n = 4 = n^{2}(2n^{2}- 1) = 4^{2}(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****.**