insidcode
ProblemsDuelLeaderboardStats
Sign In
  1. Home
  2. Problems
  3. Find the sum of all digits of a number repeatedly until a single digit is obtained (Digital Root).

Find the sum of all digits of a number repeatedly until a single digit is obtained (Digital Root).

Difficulty: Medium

Phase: 6 · Mixed Logical Challenges

XP Reward: 20 XP

Topics: Mixed Logical Challenges, Medium

Supported Languages: Python, JavaScript, C, C++, Java

Problem Description

Given non-negative integer N, find the sum of all digits repeatedly until a single digit is obtained (Digital Root). Input Format: Read input from standard input (stdin). Output Format: Print the result to standard output (stdout).

Constraints

  • -10^9 <= N <= 10^9

Examples

Example 1

Input: 9875

Output: 2

Explanation: Sample execution for input 9875