From e1a4ff61aa384b9241081cba0d2ab220996e559a Mon Sep 17 00:00:00 2001 From: Mattrixwv Date: Fri, 28 May 2021 16:13:56 -0400 Subject: [PATCH] Updated Algorithms --- Problem30.m | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Problem30.m b/Problem30.m index 687663f..a2dc52e 100644 --- a/Problem30.m +++ b/Problem30.m @@ -27,6 +27,7 @@ TOP_NUM = 1000000; %This is the largest number that will be check BOTTOM_NUM = 2; %Starts with 2 because 0 and 1 don't count POWER_RAISED = 5; %This is the power that the digits are raised to sumOfFifthNumbers = []; %This is an array of the numbers that are the sum of the fifth power of their digits +sumOfArray = 0; %This is the sum of the sumOfFifthNumbers array %Start the timer startTime = clock(); @@ -48,11 +49,13 @@ for currentNum = BOTTOM_NUM : TOP_NUM end end +sumOfArray = sum(sumOfFifthNumbers); + %Stop the timer endTime = clock(); %Print the results -printf("The sum of all the numbers that can be written as the sum of the fifth powers of their digits is %d\n", sum(sumOfFifthNumbers)) +printf("The sum of all the numbers that can be written as the sum of the fifth powers of their digits is %d\n", sumOfArray) printf("It took %f seconds to run this algorithm\n", etime(endTime, startTime)) end