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 DSA concepts with the **DSA Self Paced Course** at a student-friendly price and become industry ready.

## Recommended Posts:

- Sum of cubes of first n odd natural numbers
- Difference between Sum of Cubes and Sum of First N Natural Numbers
- Count numbers from given range having odd digits at odd places and even digits at even places
- Sum of alternating sign cubes of first N Natural numbers
- Sum of range in a series of first odd then even natural numbers
- Average of Cubes of first N natural numbers
- Sum of cubes of first n even numbers
- Count of integers in a range which have even number of odd digits and odd number of even digits
- Check if a number has an odd count of odd divisors and even count of even divisors
- Minimum value of K such that sum of cubes of first K natural number is greater than equal to N
- Count set bits in the Kth number after segregating even and odd from N natural numbers
- Count of N-digit Numbers having Sum of even and odd positioned digits divisible by given numbers
- Sum of all odd natural numbers in range L and R
- Numbers less than N that are perfect cubes and the sum of their digits reduced to a single digit is 1
- Sum of fourth powers of first n odd natural numbers
- Sum of fourth power of first n even natural numbers
- Count numbers in given range such that sum of even digits is greater than sum of odd digits
- Sum of elements in range L-R where first half and second half is filled with odd and even numbers
- Generate an array of given size with equal count and sum of odd and even numbers
- Count total number of N digit numbers such that the difference between sum of even and odd digits is 1

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.