Python Compiler
import math num = 12; 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
The sum of digit 12: 3
×
Save as
Private
Tag
AJAX
Canvas
CSS
Google Charts
HTML
Javascript
jQuery
JSON
SASS
SVG
Description
Save