Question: (The code must be done in Java and can only use RECURSION.) Find the sum of digits of a positive integer number Sum = number
(The code must be done in Java and can only use RECURSION.)
Find the sum of digits of a positive integer number
Sum = number itself if (number is a single digit)
otherwise sum = the last digit of the number + the sum of rest of the digits of the number.
Use this method: public int sumOfDigits(int number)
Test this method with following input numbers: 0, 101, 1, 231214, 734
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
