Finding n | A formula based Java program to find sum of series with cubes of first n natural numbers ; Driver Function
class GFG { static int magicOfSequence ( int N ) { return ( N * ( N + 1 ) / 2 ) + 2 * N ; } public static void main ( String [ ] args ) { int N = 6 ; System . out . println ( magicOfSequence ( N ) ) ; } }