... how many positive integers less than n have digits that sum up to m:

In [197]: def prttn(m, n):
    tot = 0
    for i in range(n):
        s = str(i)
        sum = 0
        for j in range(len(s)):
            sum += int(s[j])
        if sum == m:
            tot += 1
    return tot
   .....:

In [207]: prttn(25, 10000)
Out[207]: 348

any suggestion for pythonizin' it?

bye
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to