Find the first N integers such that the sum of their digits is equal to 10 | Function to return the sum of digits of n ; Add the last digit to the sum ; Remove last digit ; Return the sum of digits ; Function to print the first n numbers whose sum of digits is 10 ; First number of the series is 19 ; If the sum of digits of the current number is equal to 10 ; Print the number ; Add 9 to the previous number ; Driver code
def sum ( n ) : NEW_LINE INDENT sum = 0 ; NEW_LINE while ( n ) : NEW_LINE INDENT sum = sum + n % 10 ; NEW_LINE n = n // 10 ; NEW_LINE DEDENT return sum ; NEW_LINE DEDENT def firstN ( n ) : NEW_LINE INDENT num = 19 ; cnt = 1 ; NEW_LINE while ( cnt != n ) : NEW_LINE INDENT if ( sum ( num ) == 10 ) : NEW_LINE INDENT print ( num , end = " ▁ " ) ; NEW_LINE cnt += 1 ; NEW_LINE DEDENT num += 9 ; NEW_LINE DEDENT DEDENT if __name__ == " _ _ main _ _ " : NEW_LINE INDENT n = 10 ; NEW_LINE firstN ( n ) ; NEW_LINE DEDENT