Find K distinct positive odd integers with sum N | C # implementation to find K odd positive integers such that their sum is equal to given number ; Function to find K odd positive integers such that their sum is N ; Condition to check if there are enough values to check ; Driver Code
using System ; public class GFG { static void findDistinctOddSum ( int n , int k ) { if ( ( k * k ) <= n && ( n + k ) % 2 == 0 ) { int val = 1 ; int sum = 0 ; for ( int i = 1 ; i < k ; i ++ ) { Console . Write ( val + " ▁ " ) ; sum += val ; val += 2 ; } Console . Write ( n - sum + " STRNEWLINE " ) ; } else Console . Write ( " NO ▁ STRNEWLINE " ) ; } public static void Main ( String [ ] args ) { int n = 100 ; int k = 4 ; findDistinctOddSum ( n , k ) ; } }