Logo
IconChallenge
Icon
IconProblem
IconSolutions
IconSubmissions

Add Digits

XPChallenge Points: 10
levelLevel: Easy

Given a non-negative integer num,
keep adding its digits together until the result is a single digit,
then return that single digit.

Example 1:

Input: num = 38 Steps: • 3 + 8 = 11 • 1 + 1 = 2

Output: 2

Example 2:

Input: num = 0 No addition needed.

Output: 0

to Continue
like
dislike

Accepted:

Submission:

IconReport an issue
Icon
IconCode
IconYou need toto run or submitYou need toto run or submit
IconTest Case
IconTest Result