Created
November 17, 2011 20:43
-
-
Save strax/1374459 to your computer and use it in GitHub Desktop.
First negative element of an array, recursively
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public int firstNegative(int[] numbers, int...i) { | |
return ((i = (i != null ? i : 0)) > numbers.length()) | |
? 0 | |
: ((numbers[i] < 0) | |
? numbers[i] | |
: firstNegative(numbers, i+1)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment