Find the sum of n terms of the series 1 , 8 , 27 , 64 ... . | Java program to find the sum of n terms ; Function to calculate the sum ; Return total sum ; Driver code
import java . io . * ; class GFG { static int calculateSum ( int n ) { return ( int ) Math . pow ( n * ( n + 1 ) / 2 , 2 ) ; } public static void main ( String [ ] args ) { int n = 4 ; System . out . println ( calculateSum ( n ) ) ; } }