mirror of
https://bitbucket.org/Mattrixwv/projecteuleroctave.git
synced 2025-12-06 17:43:57 -05:00
Added solution for problem 35
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
function [] = Problem34()
|
||||
%ProjectEuler/ProjectEulerOctave/Problem34.lua
|
||||
%Matthew Ellison
|
||||
% Createe: 06-01-21
|
||||
% Created: 06-01-21
|
||||
%Modified: 06-01-21
|
||||
%Find the sum of all numbers which are equal to the sum of the factorial of their digits
|
||||
%{
|
||||
@@ -22,13 +22,13 @@ function [] = Problem34()
|
||||
%}
|
||||
|
||||
%Setup the variables
|
||||
|
||||
%Start the timer
|
||||
startTime = clock();
|
||||
MAX_NUM = 1499999; %The largest num that can be the sum of its own digits
|
||||
numberFactorials = []; %Holds the pre-computed factorials of the numbers 0-9
|
||||
totalSum = 0; %Holds the sum of all numbers equal to the sum of their digit's factorials
|
||||
|
||||
%Start the timer
|
||||
startTime = clock();
|
||||
|
||||
%Pre-compute the possible factorials from 0! to 9!
|
||||
for cnt = 1 : 9
|
||||
numberFactorials(cnt) = factorial(cnt);
|
||||
|
||||
Reference in New Issue
Block a user