Data Structures & AlgorithmsModerateTCS NQT Digital · Accenture
Problem: The digital root of a positive integer is obtained by repeatedly summing its decimal digits until a single digit remains. What is the digital root of 2^30?
- A. 1
- B. 2
- C. 0
- D. 3
Correct answer: A. 1
The digital root equals 1 + (n − 1) mod 9 for positive n, which can be used as a check. Summing the digits only once gives a two-digit intermediate, not the root.
More Coding Interview Problems questions
- Problem: How many integers n with 1 ≤ n ≤ 1000 have decimal digits summing to exactly 10?
- Problem: What is the smallest positive integer n such that n! is divisible by 10⁶ (that is, n! has at least six trailing zeros in base 10)?
- Problem: Children stand in a line with ratings [1, 0, 2]. Each child gets at least one candy, and a child with a higher rating than a…
- Problem: Find the maximum amount of water held between two vertical lines of heights [1, 8, 6, 2, 5, 4, 8, 3, 7] (the water is limited by…
- Problem: What is the largest integer x with x² ≤ 2,000,000,000 (the floor of the square root of 2 × 10⁹)?
- Problem: What is the sum of the first 50 odd positive integers (1 + 3 + 5 + … + 99)?