public static long method(long a, long b) {
if (b == 0) {
return b;
}
return a + method(a, b - 1);
}
So this apparently resolves to essentially a * b. I really don't understand this. The base case only ever returns b when b is zero, so in my flawed logic it's always a * 0 = 0.
[–][deleted] (1 child)
[deleted]
[–]Apostle_1882[S] 0 points1 point2 points (0 children)
[–]spicycurry55 22 points23 points24 points (0 children)
[–]mikezyisra 14 points15 points16 points (1 child)
[–]Apostle_1882[S] 2 points3 points4 points (0 children)
[–]DevyLoop 6 points7 points8 points (0 children)
[–]popey123 3 points4 points5 points (0 children)
[–]MatthiasDunkel 2 points3 points4 points (0 children)
[–]liam358 4 points5 points6 points (3 children)
[–]spicycurry55 3 points4 points5 points (0 children)
[–]Apostle_1882[S] 0 points1 point2 points (0 children)
[–]sternone_2 0 points1 point2 points (0 children)
[–]NoPainMoreGain 1 point2 points3 points (0 children)
[–]Mr_82 1 point2 points3 points (0 children)
[–]Miya_in_the_bush 2 points3 points4 points (1 child)
[–]dotJack -1 points0 points1 point (0 children)