<jupyter_start><jupyter_text>The number 512 is interesting because it is equal to the sum of its digits raised to some power: 5 + 1 + 2 = 8, and $8^3$ = 512.  Another example of a number with this property is 614656 = $28^4$.We shall define $a_{n}$ to be the $n^{th}$ term of this sequence and insist that a number must contain at least two digits to have a sum.You are given that $a_{2}$ = 512 and $a_{10}$ = 614656.Find $a_{30}$.<jupyter_code>def add_all_digits(x):
    return sum(map(int, str(x)))

a = []
n = 30

for sum_of_digit in range(2, 1000):
    for square in range(2, 100):
        an = sum_of_digit ** square
        if add_all_digits(an) == sum_of_digit: 
            a.append(an)

a.sort()
print("a({}) = {}".format(n, a[n-1]))<jupyter_output>a(30) = 248155780267521
{'fraction_non_alphanumeric': 0.1357234314980794, 'fraction_numerical': 0.08194622279129321, 'mean_word_length': 3.710843373493976, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '65717', 'license': 'MIT', 'n_tokens_mistral': 334, 'n_tokens_neox': 282, 'n_words': 101, 'path': '9_coding quizzes/04_digit_power_sum.ipynb', 'repo_name': 'lucaseo/TIL', 'size': '781'}