Digital Root Problem

Digital Root Problem — ExecCode School DSA Practice

Solve the Digital Root problem on ExecCode. Free online school DSA practice in Numbers & Math Logic. Write and run code in Java, C++, Python — no signup required to run.

Problem description

Given a non-negative integer N, compute its digital root. Your task is to solve Digital Root. The digital root is the single-digit value obtained by an iterative process of summing digits.

Examples

Input 38; Output 2. Input 0; Output 0

Constraints

0<=N<=10^9

Practice Digital Root free on ExecCode. Browse DSA problems, topic map, and placement guides.