def problem_30_narcissistic_number(power):
    """ Problem 30: Find sum of numbers that can be written as the sum of powers of their digits.

    Args:
        power (int): The exponent of the digits.
    """
    # find limit to search
    limit = len(str(9**power))*(9**power)
    valid_numbers = []
    for number in range(2, limit, 1):
        sum_of_powers_of_digits = 0
        for char in str(number):
            sum_of_powers_of_digits += int(char) ** power
        if sum_of_powers_of_digits == number:
            valid_numbers.append(number)
    return sum(valid_numbers)