public static int totient(int a) {
		// first find prime factors, then calculate those explicitly
		// phi(m*n) = phi(m)*phi(n) if n and m are relatively prime
		// phi(p^k) = p^(k-1) * (p-1) if p is prime

		Map<Integer, Integer> primeFactors = primeFactors(a);
		int result = 1;
		for (Integer p : primeFactors.keySet()) {
			Integer k = primeFactors.get(p);

			result *= Math.pow(p, k - 1) * (p - 1);
		}
		return result;
	}