You can download this code by clicking the button below.
This code is now available for download.
Calculate the sum of all digits of an integer.
Technology Stack : Built-in Python libraries
Code Type : Function
Code Difficulty :
def sum_digits(n):
total = 0
while n > 0:
total += n % 10
n //= 10
return total