diff --git a/Problem30.lua b/Problem30.lua index 0fb2f23..ea32c67 100644 --- a/Problem30.lua +++ b/Problem30.lua @@ -55,6 +55,7 @@ local TOP_NUM = 1000000; --This is the largest number that will be checked local BOTTOM_NUM = 2; --Starts with 2 because 0 and 1 don't count local POWER_RAISED = 5; --This is the power that the digits are raised to local sumOfFifthNumbers = {}; --This is a table of the numbers that are the sum of the fifth power of their digits +local sum = 0; --This is the sum of the sumOfFifthNumbers array --Start the timer timer:start(); @@ -75,11 +76,13 @@ for currentNum = BOTTOM_NUM, TOP_NUM do end end +sum = getSumOfTable(sumOfFifthNumbers); + --Stop the timer timer:stop(); --Print the results -io.write("The sum of all the numbers that can be written as the sum of the fifth powers of their digits is " .. getSumOfTable(sumOfFifthNumbers) .. '\n'); +io.write("The sum of all the numbers that can be written as the sum of the fifth powers of their digits is " .. sum .. '\n'); io.write("It took " .. timer:getString() .. " to run this algorithm\n");