We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents a40e638 + 19ffc10 commit 8b181a8Copy full SHA for 8b181a8
algorithms/math/sumofdigits.py
@@ -1,8 +1,11 @@
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
+# This is to find the sum of digits of a number until it is a single digit
+
+def sum_of_digits(n):
+ n = int(input()) # here n is the number
+ if n % 9 != 0:
+ print(n % 9)
+ else:
8
+ print("9")
9
10
+# This method reduces time complexity by a factor of n and also without using any loop
11
0 commit comments