Split a number as sum of K numbers which are not divisible by K | Function to split into K parts and print them ; Print 1 K - 1 times ; Print N - K + 1 ; Print 1 K - 2 times ; Print 2 and N - K ; Driver code
def printKParts ( N , K ) : NEW_LINE INDENT if ( N % K == 0 ) : NEW_LINE INDENT for i in range ( 1 , K ) : NEW_LINE INDENT print ( "1 , ▁ " ) ; NEW_LINE DEDENT print ( N - ( K - 1 ) , end = " " ) ; NEW_LINE DEDENT else : NEW_LINE INDENT if ( K == 2 ) : NEW_LINE INDENT print ( " Not ▁ Possible " , end = " " ) ; NEW_LINE return ; NEW_LINE DEDENT DEDENT for i in range ( 1 , K - 1 ) : NEW_LINE INDENT print ( 1 , end = " , ▁ " ) ; NEW_LINE DEDENT print ( 2 , " , ▁ " , ( N - K ) , end = " " ) ; NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT N = 18 ; NEW_LINE K = 5 ; NEW_LINE printKParts ( N , K ) ; NEW_LINE DEDENT