Skip to content

Instantly share code, notes, and snippets.

@jromeem
Created October 22, 2016 02:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jromeem/67f48103ddbec50ffae8f0daaa06da81 to your computer and use it in GitHub Desktop.
Save jromeem/67f48103ddbec50ffae8f0daaa06da81 to your computer and use it in GitHub Desktop.
int[] numbers = {1,2,3,6,1,6,48,38,77,23};
void setup() {
int x = findMaximum(numbers);
println(x);
}
int findMaximum(int[] someNumbers) {
int currentMax = someNumbers[0];
for(int i=0; i<someNumbers.length; i++) {
int thisNumber = someNumbers[i];
if (thisNumber > currentMax) {
currentMax = thisNumber;
}
}
return currentMax;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment