Search⌘ K
AI Features

Add Digits

Add Digits takes a nonnegative integer and asks you to repeatedly sum its digits until one digit remains, returning that final value without loops or recursion.

Statement

Given an integer num, repeatedly sum all of its digits until the resulting value is a single digit, then return that value.

Note: Could you solve this without any loop or recursion in O(1)O(1) ...