Lecture Notes on 29 July 2013 public static int f (int n) { if (n == 0) return 1; else return n * f (n - 1) + 1; } public static int f (int n) { int sum = 0; for (int i = 0; i <= n; i++) { sum = sum * i + 1; } return sum; } public static boolean isEqual (int[] a, int[] b) { if (a.length != b.length) return false; for (int i = 0; i < a.length; i++) { if (a[i] != b[i]) return false; } return true; } public static boolean isSorted (int[] a) { for (int i = 1; i < a.length; i++) { if (a[i - 1] > a[i]) return false; } return true; } public static String rotateRight (String s, int n) { n = n % s.length(); return (s.substring (s.length() - n) + s.substring (0, s.length() - n)); } public static void grep (String inFile, String word) throws IOException { File input = new File (inFile); Scanner sc = new Scanner (input); while (sc.hasNextLine()) { String line = sc.nextLine(); if (line.indexOf (word) > -1) System.out.println (line); } sc.close() }