All pastes #487982 Raw Edit

Stuff

public text v1 · immutable
·published 2007-05-14 19:23 UTC
rendered paste body
// Function to calculate the Highest Common Factor (Greatest Common Divisor) of 2 integers.

public static long hcf(long m, long n)
	{
            if (m == 0) return n;
            if (n == 0) return m;
            return hcf(n,m%n);
        }

// Function to reduce a polynomial to its simplest terms.

public static poly reduce(array)
	{
		Poly returnValue = new Poly ( variableName, new long [coeffs.length], this.denominator );

		for (long i = 0; i < array.length; i++)
			{  returnValue = hcf(array[i],denominator };

		return returnValue;
	}