Find any K distinct odd integers such that their sum is equal to N | Function to find K odd integers such that their sum is N ; Condition to check if there exist such K integers ; Loop to find first K - 1 distinct odd integers ; Final Kth odd number ; Driver code
def oddIntegers ( n , k ) : NEW_LINE INDENT if ( n % 2 != k % 2 ) : NEW_LINE INDENT print ( " - 1" ) ; NEW_LINE return ; NEW_LINE DEDENT sum = 0 ; NEW_LINE i = 1 ; NEW_LINE j = 1 ; NEW_LINE while ( j < k ) : NEW_LINE INDENT sum += i ; NEW_LINE print ( i , end = " ▁ " ) ; NEW_LINE i += 2 ; NEW_LINE j += 1 ; NEW_LINE DEDENT finalOdd = n - sum ; NEW_LINE print ( finalOdd ) ; NEW_LINE DEDENT if __name__ == " _ _ main _ _ " : NEW_LINE INDENT n = 10 ; NEW_LINE k = 2 ; NEW_LINE oddIntegers ( n , k ) ; NEW_LINE DEDENT