Add Digits
Easy · Math & Number Theory · about 5 minutes
Asked at Amazon, Google, Microsoft, Adobe, Bloomberg, Electronic Arts, Autodesk.
Take the non-negative integer num, add its digits together, and keep doing that to the result until only one digit remains. Return that digit. Is there an O(1) formula?