Dashboard Temp Share Shortlinks Frames API

HTMLify

digital_sum.py
Views: 532 | Author: abh
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
def digital_sum(n: int):
    s = 0
    while n:
        s += n % 10
        n //= 10
    return s

def digital_sum(n: int):
    return sum([int(d) for d in str(n)])

def digital_sum(n: int):
    s = 0
    for d in str(n):
        s += int(d)
    return s