We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 33f5116 commit e27802fCopy full SHA for e27802f
1 file changed
algorithms/math/sumofdigits.py
@@ -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