CSC300 / CSC402: Does this work? [13/14] |
01 |
public static int numFives (double[] a) { if (a.length == 0) return 0; int result = numFives (Arrays.copyOfRange (a, 1, a.length)); if (a[0] == 5.0) result += 1; return result; } |
This corresponds to the following code in python:
01 |
def numFives (a): if len(a) == 0: return 0 result = numFives (a[1:]) if (a[0] == 5.0): result += 1 return result |