Python Shorts — Digits Sum

John Clark Craig
4 min readFeb 22

There’s one algorithm that’s 25 times faster!

Image courtesy of DALL-E

Every once in a while, I come across some discussion involving number games or other interesting math, where the sum of all the digits in an integer is to be found repeatedly until only one digit is left. I decided to write a short Python function to do this calculation, so I could add it to my bag of Python tricks.

John Clark Craig

Author, inventor, entrepreneur — passionate about alternate energy, technology, and how Python programming can help you hack your life.