Project Euler 119 - Digit Power Sum

Official link:

Thought Process

There were 2 thought processes for me:

  1. Go through numbers, check if the sum of the digits of the number to the power of an integer is the same number

  2. Go through some numbers, raise them all to the power of 2 through 50 (or some big number), and see if the sum of this is equal to the number

Way 2 is much much faster! See here for Sum of Digits Function

I set up a function which only stopped when 50 numbers of the given condition were found to be sure that I wouldnt accidentally skip over the 30th number

Interactive Code

Enter a number (yourinput)

Code will output the a(yourinput)