protected static Map<AlgebraicParticle, Integer> factors(AlgebraicParticle algebra){
		LinkedHashMap<AlgebraicParticle, Integer> factors = new LinkedHashMap<AlgebraicParticle, Integer>();
		if(algebra instanceof Term){
			Term term = (Term) algebra;
			for(int i = 0; i < term.length(); i++) combine(factors, factors(term.get(i)));
			if(!algebra.sign()) addToMap(factors, Number.NEGATIVE_ONE);
		}
		else if(algebra instanceof Number && ((Number)algebra).isInteger()){
			Number number = (Number) algebra;
			//calculate the primes
			Long[] primes = Util.primeFactors(Long.parseLong(number.getInteger()));
			//add them to the map
			for(long prime : primes) addToMap(factors, new Number(Long.toString(prime)));
			//if the number is negative, add -1 to the map
			if(!algebra.sign()) addToMap(factors, Number.NEGATIVE_ONE);
		}
		else addToMap(factors, algebra);
		return factors;
	}