Sum of alternating sign cubes of first N Natural numbers | C # implementation to compute the sum of cubes with alternating sign ; Function to compute sum of the cubes with alternating sign ; Driver code
using System ; class GFG { static int summation ( int N ) { int co = ( N + 1 ) / 2 ; int ce = ( N ) / 2 ; int se = 2 * ( ( ce * ( ce + 1 ) ) * ( ce * ( ce + 1 ) ) ) ; int so = ( co * co ) * ( 2 * ( ( co * co ) ) - 1 ) ; return so - se ; } public static void Main ( String [ ] args ) { int n = 3 ; Console . WriteLine ( summation ( n ) ) ; } }