Hi,
I have a recursive method to find the sum of a given number that's greater than 10 respectively.
static int sum(int n) { if(n < 10) { return n; } else { return sum(n/10) + (n % 10); } }
I know this splits the number up into lets say 256 was entered 2 + 5 + 6 = 13 the sum.
My question is how exactly does it split it up.
I only got this through keyboard bashing and I want to be able to see recursion in my head properly.
Many thanks,
Seán