Homepage and blog of Miles Jonathan Phillips, UK based architect

Site based on Lanyon, running on Jekyll

© 2024. All rights reserved.

MJP

architect • coder • strategist • musician • educator

Implement a recursive function that sums the digits of a number until only one digit remains.

sum_digits(11) # 2 # 1 + 1 = 2 sum_digits(99) # 9 # 9 + 9 = 18, # 1 + 8 = 9