Skip to content

Instantly share code, notes, and snippets.

@strax
Created November 17, 2011 20:43
Show Gist options
  • Save strax/1374459 to your computer and use it in GitHub Desktop.
Save strax/1374459 to your computer and use it in GitHub Desktop.
First negative element of an array, recursively
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