Added a few comments to enhance understanding

This commit is contained in:
2018-09-26 11:17:57 -04:00
parent 2468bd4f80
commit c49d8a71ab
2 changed files with 3 additions and 0 deletions

View File

@@ -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 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 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 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 %Print the value
value value

View File

@@ -5,6 +5,8 @@
%Setup the variables %Setup the variables
counter = 1000; counter = 1000;
primeList = []; primeList = [];
%Cycle through the prime numbers until you get the correct number
while(size(primeList)(2) < 10001) while(size(primeList)(2) < 10001)
primeList = primes(counter); primeList = primes(counter);
counter += 1000; counter += 1000;