forked from souravjain540/Basic-Python-Programs
- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdigital_root.py
More file actions
Latest commit
47 lines (24 loc) · 570 Bytes
/
Copy pathdigital_root.py
File metadata and controls
47 lines (24 loc) · 570 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
"""
A digital root of a number can be gitten by adding each of the individual characters until they reach a 1 digit number
e.g
the digital root of 45893 is
4+5+8+9+3
that will give us 29
and adding up digits if 29
2+9
will give us 11
adding that
1+1
will give us 2
"""
defdig_root(n):
'''
I will try to implement this without using type casting in my code
'''
div , res=10, 0
whilen>0:
res+=n%div
n//=div
returnresifres<10elsedig_root(res)
#print(dig_root(45893))
print(dig_root (int(input())))