Project Euler 30 - Digit fifth powers

Official link: https://projecteuler.net/problem=30

Thought Process

My initial thought was I want to reduce my search range because for example 2^5 = 64, so any number < 64 can never be a fifth power digit sum number (This is how I will refer a number which can potentially be equal to the sum of fifth powers of their digits)

In the reverse way 9^5 = 59049 is the most a single digit can contribute, I tried a few more test cases and noticed the following:

  1. 6 * 9^5 = 354294

  2. 7 * 9^5 = 413343

This means that the fifth power digit sum of 9,999,999 = 413,343 which is a 6 digit number, this implies that any number that is more than 6 digits long can never be a fifth power digit sum!

We have reduced our search range to 64 - 354294

I modified by digit sum function to return the sum of all digits to the fifth power, I loop through the range as see if digit_sum(x) = x

Interactive Code

No interactive code for this one, but I have added some hints and my code below