text: Represent N as sum of K even numbers | C ++ implementation to represent N as sum of K even numbers ; Function to print the representation ; N must be greater than equal to 2 * K and must be even ; Driver Code
code: #include <bits/stdc++.h> NEW_LINE using namespace std ; void sumEvenNumbers ( int N , int K ) { int check = N - 2 * ( K - 1 ) ; if ( check > 0 && check % 2 == 0 ) { for ( int i = 0 ; i < K - 1 ; i ++ ) { cout << "2 ▁ " ; } cout << check ; } else { cout << " - 1" ; } } int main ( ) { int N = 8 ; int K = 2 ; sumEvenNumbers ( N , K ) ; return 0 ; }