From c49d8a71ab095bb224528ffc405dc83f42bda4dd Mon Sep 17 00:00:00 2001 From: Matthew Ellison Date: Wed, 26 Sep 2018 11:17:57 -0400 Subject: [PATCH] Added a few comments to enhance understanding --- ProjectEuler/Problem6.m | 1 + ProjectEuler/Problem7.m | 2 ++ 2 files changed, 3 insertions(+) diff --git a/ProjectEuler/Problem6.m b/ProjectEuler/Problem6.m index adbb305..9b168ab 100644 --- a/ProjectEuler/Problem6.m +++ b/ProjectEuler/Problem6.m @@ -8,6 +8,7 @@ squares = nums.^2; %Square every number in the list nums sumOfSquares = sum(squares); %Get the sum of all the elements in the list squares squareOfSums = sum(nums)^2; %Get the sum of all the elements in the list nums and square the answer value = abs(squareOfSums - sumOfSquares); %Get the difference of the 2 numbers +%This could all be done on one line, but this is less confusing %Print the value value diff --git a/ProjectEuler/Problem7.m b/ProjectEuler/Problem7.m index 2bd16b5..50db288 100644 --- a/ProjectEuler/Problem7.m +++ b/ProjectEuler/Problem7.m @@ -5,6 +5,8 @@ %Setup the variables counter = 1000; primeList = []; + +%Cycle through the prime numbers until you get the correct number while(size(primeList)(2) < 10001) primeList = primes(counter); counter += 1000;