This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author David Srebnick
Recipients David Srebnick
Date 2020-07-03.12:26:22
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1593779182.53.0.05415381128.issue41201@roundup.psfhosted.org>
In-reply-to
Content
The following program is one way of computing the sum of digits in a number.  It works properly for the first case, but fails for the second one.

def digitsum(num):
    digsum = 0
    tnum = num
    while tnum > 0:
        print("tnum = %d, digsum = %d" % (tnum,digsum))        
        digsum += (tnum % 10)
        tnum = int((tnum - (tnum % 10)) / 10)
    return digsum

print(digitsum(9999999999999999))
print(digitsum(99999999999999999))
History
Date User Action Args
2020-07-03 12:26:22David Srebnicksetrecipients: + David Srebnick
2020-07-03 12:26:22David Srebnicksetmessageid: <1593779182.53.0.05415381128.issue41201@roundup.psfhosted.org>
2020-07-03 12:26:22David Srebnicklinkissue41201 messages
2020-07-03 12:26:22David Srebnickcreate