✕
Recursion and BacktrackingCoding problems
Recursion and Backtracking: coding problems
Write a program that reads the input and prints the answer. Run checks it against every test, including hidden ones.
0 of 7 solved
A warehouse labels each crate with a long serial number. The checksum tool adds up the decimal digits of the serial number. The team wants the tool written as a recursive function. Each call takes off the last digit with
% 10and passes the rest with/ 10, and the base case is a single digit.Read one number and print the sum of its digits.
**Constraints:** the number is from 0 to 1000000000000000000. Use
long long.Input. One integer n, from 0 to 1000000000000000000.
Output. One integer: the sum of the decimal digits of n.
Example 1 input
472
Output
13
Example 2 input
1000000000000000000
Output
1