Program to find sum of series 1 + 2 + 2 + 3 + 3 + 3 + . . . + n | Java Program to find sum of series 1 + 2 + 2 + 3 + . . . + n ; Function that find sum of series . ; Driver Code
public class GfG { static int sumOfSeries ( int n ) { return ( n * ( n + 1 ) * ( 2 * n + 1 ) ) / 6 ; } public static void main ( String s [ ] ) { int n = 10 ; System . out . println ( sumOfSeries ( n ) ) ; } }