Python Compiler
import math num = int(input("Enter a (int) number: ")); copyNum = num; total = 0; #Add Each digit from last digit. while(copyNum != 0): total += copyNum % 10 copyNum = math.floor(copyNum / 10) print("The sum of digit %d: %d" % (num, total))
OUTPUT
Enter a (int) number: 12345
The sum of digit 12345: 15
×

Save as Private