Toggle navigation
Home
Latest pastes
FAQ
Random
BitBin is shutting down!
Register
Login
Python Tutorial #8 :Sum of digits
SUBMITTED BY:
Guest
DATE:
Dec. 16, 2013, 8:41 a.m.
FORMAT:
Python
SIZE:
293 Bytes
Raw
Download
Tweet
HITS:
825
Go to comments
Report
# find sum of digits
# C pgm in Python
# 2.7 : raw_input
n
=
input
(
"enter an integer : "
)
print
(
n
,
type
(
n
))
n
=
int
(
n
)
print
(
n
,
type
(
n
))
total
=
0
i
=
0
while
n
:
total
+=
n
%
10
n
//=
10
i
+=
1
print
(
total
)
print
(
"# of iterations : "
,
i
)
Please enable JavaScript to view the
comments powered by Disqus.
comments powered by
Disqus