Reduce to Single Digit
CodeChefOpen on judge ↗
Given a number N, the task is to reduce it to a single-digit number by repeatedly subtracting the adjacent digits. That is, in the first iteration, subtract all of the adjacent digits to generate a new number, if this number contains more than one digit, repeat the same process until it becomes a single-digit number. Input: N = 6972 Output: 2 | 6 – 9 | = 3 | 9 – 7 | = 2 | 7 – 2 | = 5 After fir
HINT LADDERno hints yet
L1 Observation
L2 Technique
L3 Approach
L4 Pseudo-code
🔒
L5 Full solution
L5 unlocks only if you insist twice
solution.cppC++17
CodeSearch Tutor
Hints, not spoilers — it won’t hand over the full solution unless you insist.
Sign in to chat with the tutor and save your progress.
Sign in to start