All pastes #761342 Raw Edit

Someone

public text v1 · immutable
·published 2007-11-04 20:22 UTC
rendered paste body
    public int max(int[] v)
    {  
        if(v.length == 1)
        {
            return v[0]; // Returns the first and only element.
        }            
        if(v[0] > v[1]) // Is the first element bigger than the second?
        { // If so, we ignore the second element, and replace it with the first.
            v[1] = v[0]; 
        }
        int[] u = new int[v.length - 1]; // New array with the size of v minus one.
        for(int i = 0; i < u.length; i++) 
        {  // Skip the first element in v as it's always smaller or equal to the second one. 
            u[i] = v[i + 1]; 
        }
        return max(u); // Calls this method on our new array which only consists of one element.
    } 
}