Mystery Demo 1
Live JS — Step-Through Demo
// Java — What does this return? public static int mystery(int[] a, int i, int s) { if (i == a.length) { return s; } else { return mystery(a, i + 1, s + a[i] * a[i]); } }//end mystery
let a = [];
let r = mystery(a, 0, 0);
| Call: | Recursive Call: | 'Tail' Stmt Return | Result: |
|---|