// Assignment 13 solutions abstract public class Basic { public static int sum_of_squares (int x, int y) { return (x * x) + (y * y); } // end sum_of_squares public static int fact (int n) { if (n == 0) return 1; else return n * fact(n - 1); } // end fact public static int fib (int n) { if (n <= 1) return n; else return fib(n - 1) + fib(n - 2); } // end fib // A fun iterative solution. public static int num_reverse (int n) { int from = n; int to = 0; while (0 < from) { to = (to * 10) + (from % 10); from = from / 10; } return to; } // end num_reverse } // end class Basic