Loop to iterate from 1 to N and calculating number of natural numbers for every ' i ' th digit .
for i in range ( 1 , N + 1 ) : NEW_LINE INDENT sum += ( B - 1 ) * pow ( B , i - 1 ) NEW_LINE DEDENT return sum NEW_LINE