From caa3eda85b3333531ab021179d9c2dcc7bcc3bae Mon Sep 17 00:00:00 2001 From: Mattrixwv Date: Fri, 28 May 2021 16:13:54 -0400 Subject: [PATCH] Updated Algorithms --- Problem30.lua | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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");