mirror of
https://bitbucket.org/Mattrixwv/projecteuleroctave.git
synced 2025-12-06 17:43:57 -05:00
Updated Algorithms
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user