All pastes #488043 Raw Edit

Miscellany

public java v1 · immutable
·published 2007-05-14 19:57 UTC
rendered paste body
public class Poly	{	private String variableName;	private long [] coeffs;	private long denominator;// Constructorspublic Poly ( String polyVariableName, long [] polyCoeffs, long polyDenominator )	{		variableName = polyVariableName;		coeffs = polyCoeffs;		denominator = polyDenominator;	}// Debug quality printing.  Takes a polynomial and displays its coefficents.public String debugPrint ()	{		String returnValue = "(";		returnValue = returnValue + coeffs [0] + "*" + variableName + "^0";				for (int i = 1; i < coeffs.length; i++)			{ returnValue = returnValue + " + " + coeffs [i] + "*" + variableName + "^" + i; };		returnValue = returnValue + ")/";		returnValue = returnValue + denominator;		return returnValue;	}// 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.