Programming a recursive function: calculate the sum of all the digit

Report a typo

Write a recursive function digitSum(n: Int): Int, which calculates the sum of all the digits in n.

Sample Input 1:

5421

Sample Output 1:

12
Write a program in Kotlin





___

Create a free account to access the full topic