We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 63b33fc commit bf3748cCopy full SHA for bf3748c
sum_of_digits_of_a_number.py
@@ -49,7 +49,8 @@ def sum_of_digits(n: int) -> int:
49
Compute the sum of the digits of an integer.
50
51
Args:
52
- n: A non-negative integer.
+ n:Non - negative integer
53
+ If the integer is negative , it is converted to postive interger and assigned to same number
54
55
Returns:
56
Sum of digits of the number.
@@ -60,6 +61,7 @@ def sum_of_digits(n: int) -> int:
60
61
>>> sum_of_digits(405)
62
9
63
"""
64
+ n=abs(n)
65
total = 0
66
while n > 0:
67
# Add last digit and remove it from n
0 commit comments