public static int[] generateSequence(int start, int end, int steps)
    {
        // Check that there are at least two steps.
        if (steps < 2)
        {
            throw new IllegalArgumentException("There must be at least 2 steps.");
        }

        List<Integer> result = new ArrayList<Integer>();

        // Calculate the sequence using floating point, then round into the results.
        double fStart = start;
        double fEnd = end;
        double fCurrent = start;

        for (int i = 0; i < steps; i++)
        {
            fCurrent = (((fEnd - fStart) / (steps - 1)) * i) + fStart;

            roundAndAdd(result, fCurrent);
        }

        // Return the results after converting to a primitive array.
        return intListToPrimitiveArray(result);
    }
public static int [ ] generateSequence ( int start , int end , int steps ) { if ( steps < 2 ) { throw new IllegalArgumentException ( "There must be at least 2 steps." ) ; } List < Integer > result = new ArrayList < Integer > ( ) ; double fStart = start ; double fEnd = end ; double fCurrent = start ; for ( int i = 0 ; i < steps ; i ++ ) { fCurrent = ( ( ( fEnd - fStart ) / ( steps - 1 ) ) * i ) + fStart ; roundAndAdd ( result , fCurrent ) ; } return intListToPrimitiveArray ( result ) ; }
Given a start and end and a number of steps this method generates a sequence of evenly spaced integer values,
starting at the start (inclusive) and finishing at the end (inclusive) with the specified number of values in the
sequence. The sequence returned may contain less than the specified number where the integer range between start
and end is too small to contain that many.

<p/>As the results are integers, they will not be perfectly evenly spaced but a best-fit.

@param  start The sequence start.
@param  end   The sequence end.
@param  steps The number of steps.

@return The sequence.