Question: HOMEWORK 2 2 : Recursive Sum of Digits Write a function that is passed a number and returns the sum of its digits using recursion.
HOMEWORK : Recursive Sum of Digits
Write a function that is passed a number and returns the sum of its digits using recursion. For example:
tableSum of DigitsSum of Digits,
input: output:
input: output:
I'll give you a hint on the logic. The Mod operator can be a powerful tool. Let think through an example, let's say that and we have additional variables, temp and sum. This function could be easily executed with a DoWhile Loop, but you must use recursion to get credit. VBA
rirst pass through the recursive loop
temp Mod 'temp
sum sum temp
temp,
do the reqursive part
second pass through the recursive loop
temp nMod 'temp &
sum sum temp
tempquadnn
teII the code to stop nov
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
