human
Can you provide a code to find a number x such that sum of x and its digits is equal to given n given the following:
Find a number x such that sum of x and its digits is equal to given n . | utility function for digit sum.
function for finding x.
iterate from 1 to n . For every no . check if its digit sum with it isequal to n ..
if no such i found return - 1.
Driver Code"
Solution in Python:
assistant
#Here is code to find a number x such that sum of x and its digits is equal to given n .
 def digSum ( n ) :
	sum = 0 ;
	rem = 0 ;
	while ( n ) :
		rem = n % 10 ;
		sum = sum + rem ;
		n = int ( n / 10 ) ;
	return sum ;
def findX ( n ) :
	for i in range ( n + 1 ) :
		if ( i + digSum ( i ) == n ) :
			return i ;
	return - 1 ;
n = 43 ;
print ( " x ▁ = ▁ " , findX ( n ) ) ;