Consider the following recursive functions. public static int square(int n) { if (n == 0) return 0;
Fantastic news! We've Found the answer you've been seeking!
Question:
Consider the following recursive functions. public static int square(int n) { if (n == 0) return 0; return square(n-1) + 2*n - 1; } public static int cube(int n) { if (n == 0) return 0; return cube(n-1) + 3*(square(n)) - 3*n + 1; } What is the value of square(5)? cube(5)? cube(123)?
(Attached picture for easy reading)
Related Book For
Computer Organization and Design The Hardware Software Interface
ISBN: 978-0124077263
5th edition
Authors: David A. Patterson, John L. Hennessy
Posted Date: