def problem_8_7(cents):
    """ Given an infinite number of quarters (25 cents), dimes (10 cents),
    nickels (5 cents) and pennies (1 cent), write code to calculate the number
    of ways of representing n cents.
    """
    smaller_vals = {
        25: 10,
        10: 5,
        5: 1
    }

    def num_combinations(change, val):
        """ Count the number of combination of value which sum up to change.
        Args:
            change: int,
            val: int, one of 25, 10, 5 or 1
        Returns:
            int, the number of combinations.
        """
        if val == 1: # Only one way to return change using only pennies.
            return 1

        # Compute the change using smaller values first.
        smaller_val = smaller_vals[val]
        ways = num_combinations(change, smaller_val)

        # Compute change using current value and
        times = change / val
        for i in range(times):
            ways += num_combinations(change - i*val, smaller_val)

        return ways

    return num_combinations(cents, 25)