Skip to content

Commit 03158a9

Browse files
committed
fix(maths): correct recursive call in sum_of_digits_recursion
sum_of_digits_recursion() was calling sum_of_digits() (the iterative version) instead of itself in the recursive case. This meant the function was not actually recursive as its name suggests.
1 parent 791deb4 commit 03158a9

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

maths/sum_of_digits.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ def sum_of_digits_recursion(n: int) -> int:
3131
0
3232
"""
3333
n = abs(n)
34-
return n if n < 10 else n % 10 + sum_of_digits(n // 10)
34+
return n if n < 10 else n % 10 + sum_of_digits_recursion(n // 10)
3535

3636

3737
def sum_of_digits_compact(n: int) -> int:

0 commit comments

Comments
 (0)