human
Number of ways to write N as a sum of K non | Function to count the number of ways to write N as sum of k non - negative integers.
Initialise dp [ ] [ ] array.
Fill the dp [ ] [ ] with sum = m.
Iterate the dp [ ] [ ] to fill the dp [ ] [ ] array.
Condition for first column.
Else fill the dp [ ] [ ] with sum till ( i , j ).
If reach the end , then return the value.
Update at current index.
Driver Code.
Function call"
Solution in Python:
 Can you provide a code to number of ways to write N as a sum of K non and the other steps required?
assistant
#Here is code to number of ways to write N as a sum of K non and the other steps required.
 def countWays ( n , m ) :
	dp = [ [ 0 for i in range ( n + 1 ) ] for j in range ( m + 1 ) ]
	for i in range ( n + 1 ) :
		dp [ 1 ] [ i ] = 1
		if ( i != 0 ) :
			dp [ 1 ] [ i ] += dp [ 1 ] [ i - 1 ]
	for i in range ( 2 , m + 1 ) :
		for j in range ( n + 1 ) :
			if ( j == 0 ) :
				dp [ i ] [ j ] = dp [ i - 1 ] [ j ]
			else :
				dp [ i ] [ j ] = dp [ i - 1 ] [ j ]
				if ( i == m and j == n ) :
					return dp [ i ] [ j ]
				dp [ i ] [ j ] += dp [ i ] [ j - 1 ]
N = 2
K = 3
print ( countWays ( N , K ) )