rem stores the value that still remains to be distributed To keep the difference of digits minimum last rem digits are incremented by 1
for i in range ( 1 , d - rem + 1 ) : NEW_LINE INDENT num = num + str ( val ) NEW_LINE DEDENT