Program
science facts and news
Monday, July 5, 2021
Given n, take the sum of the digits of n and continue until it reaches to single-digit - Codewars solution(Python)
def
digital_root
(
n
):
x
=
sum
(
int
(
i
)
for
i
in
str
(
n
))
if
x
>
9
:
return
digital_root
(
x
)
return
x
print
(
digital_root
(
2333
))
No comments:
Post a Comment
Newer Post
Older Post
Home
Subscribe to:
Post Comments (Atom)
About Me
Roshan aryal
Kohalpur, Banke, Nepal
Hi, I'm Roshan , a student just trying to explore the world of programming
View my complete profile
No comments:
Post a Comment