CSC300 / CSC402: Does this work? [12/14] |
01 |
public static int numFives (double[] a) { return numFives(a, 0, 0); } private static int numFives (double[] a, int i, int result) { if (a.length == 0) { return 0; } if (a.length < 2) { if (a[0] == 5) result++; return result; } if (i < a.length) { if (a[0] == 5) result++; return numFives(a, i+1, result); } else { return result; } } |