-
-
Save m4hi2/b9c5f495346b31ed408d19922273e391 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def get_sum_of_individual_digits(n: int, total: int = 0) -> int: | |
if n == 0: | |
# print(total) | |
return total | |
digit = n % 10 | |
total = total + digit | |
return get_sum_of_individual_digits(n // 10, total) | |
print(get_sum_of_individual_digits(200)) | |
print(get_sum_of_individual_digits(112)) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment