Possible two sets from first N natural numbers difference of sums as D | C # program for implementing above approach ; Function returns true if it is possible to split into two sets otherwise returns false ; Driver code
using System ; class GFG { static bool check ( int N , int D ) { int temp = ( N * ( N + 1 ) ) / 2 + D ; return ( temp % 2 == 0 ) ; } static public void Main ( ) { int N = 5 ; int M = 7 ; if ( check ( N , M ) ) Console . Write ( " yes " ) ; else Console . Write ( " no " ) ; } }