public class Test { public static void towers (int n, char source, char spare, char dest) { if (n == 1) System.out.println ("Move disk from " + source + " to " + dest); else { towers (n - 1, source, dest, spare); System.out.println ("Move disk from " + source + " to " + dest); towers (n - 1, spare, source, dest); } } public static int f (int n) { if (n == 0) return 0; else return 2 * f (n - 1) + 1; } public static int f (int n) { int sum = 0; for (int i = 0; i < n; i++) { sum = 2 * sum + 1; } return sum; } public static int fib (int n) { if ((n == 0) || (n == 1)) return n; else return fib (n - 1) + fib (n - 2); } public static int sum (int n) { if (n == 1) return 1; else return n + sum (n - 1); } public static int[] incrArray (int[] a) { int[] b = new int [a.length + 100]; for (int i = 0; i < a.length; i++) { b[i] = a[i]; } return b; } public static void main (String[] args) { int[] a = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; int[] b = {9, 7, 3, 2, 1, 7, 3, 5, 8, 2}; int sum = 0; for (int i = 0; i < a.length; i++) { sum = sum + a[i]; } int scalarProduct = 0; for (int i = 0; i < a.length; i++) { scalarProduct = scalarProduct + a[i] * b[i]; } int[] newArray = incrArray (a); int[][] c = {{1, 2, 3}, {4, 5}, {7, 8, 9, 2}}; int sum2D = 0; for (int i = 0; i < c.length; i++) { for (j = 0; j < c[i].length; j++) { sum2D = sum2d + c[i][j]; } } int max = c[0][0]; for (int i = 0; i < c.length; i++) { for (j = 0; j < c[i].length; j++) { if (c[i][j] > max) max = c[i][j]; } } } }