Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static void main(String[] args) {
- int[] arr = {4, 7, 5, 6, 2};
- System.out.println(determineGreatestNum(arr, 0, arr[0]));
- }
- static public int determineGreatestNum(int[] arr, int index, int currentGreatest){
- if (index == arr.length)
- return currentGreatest;
- if (arr[index] > currentGreatest)
- currentGreatest = arr[index];
- index += 1;
- return determineGreatestNum(arr, index, currentGreatest);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement