If the current digit is zero and nonz is 1 , we can 't place it
if d == 0 and nonz : NEW_LINE INDENT continue NEW_LINE DEDENT currSum = Sum + d NEW_LINE currRem = ( rem * 10 + d ) % m NEW_LINE currF = int ( tight or ( d < num [ pos ] ) ) NEW_LINE ans += count ( pos + 1 , currSum , currRem , currF , nonz or d , num ) NEW_LINE dp [ pos ] [ Sum ] [ rem ] [ tight ] = ans NEW_LINE return ans NEW_LINE