Skip to content

Commit 9f93937

Browse files
authored
Merge pull request prabhupant#179 from avats101/master
Sumoffigitswithoutanyloop
2 parents 1d4e888 + e27802f commit 9f93937

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

algorithms/math/sumofdigits.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#This is to find the sum of digits of a number untill it is a single digit
2+
n=int(input()) #here n is the number
3+
if n%9!=0:
4+
print(n%9)
5+
else:
6+
print("9")
7+
#this method reduces time complexity by a factor of n and also without using any loop
8+

0 commit comments

Comments
 (0)