Find the sum of series 3 , 7 , 13 , 21 , 31. ... | Java program to find sum of n terms of the given series ; Function to calculate sum ; returning the final sum ; Driver Code
import java . util . * ; class GFG { static int calculateSum ( int n ) { return ( n * ( ( int ) Math . pow ( n , 2 ) + 3 * n + 5 ) ) / 3 ; } public static void main ( String arr [ ] ) { int n = 25 ; System . out . println ( calculateSum ( n ) ) ; } }