use to toggle sign in sequence .
long toggle = 1 ; for ( int i = 1 ; i <= n ; i += 2 ) { ans = ans + nCr [ n , i ] * Math . Pow ( cosTheta , n - i ) * Math . Pow ( sinTheta , i ) * toggle ; toggle = toggle * - 1 ; } return ans ; }