Monday, July 28, 2008

Minimum Fun!

/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/

package minimumfun;

/**
*
* @author dfreer
*/
public class Main {


public static int calcMinimum(int [] a, int counter, int minimum)
{
if(counter == a.length-1)
return minimum;
else
{
if(a[counter] > minimum)
{
return calcMinimum(a, ++counter, a[counter]);
}
return calcMinimum(a, ++counter, minimum);
}
}

public static int minimum(int [] a)
{
int minimum = a[0];
return calcMinimum(a, 0, minimum);
}

public static void main(String [] args)
{
int [] b = {3,4,5,6,2,5};
System.out.println(minimum(b));
}
}

No comments: