From 2ee978c7e928d99a1e3d9c498c8a00a536b69e1e Mon Sep 17 00:00:00 2001 From: Matthew Ellison Date: Wed, 26 Sep 2018 08:51:01 -0400 Subject: [PATCH] Added the 6th problem --- ProjectEuler/Problem6.m | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 ProjectEuler/Problem6.m diff --git a/ProjectEuler/Problem6.m b/ProjectEuler/Problem6.m new file mode 100644 index 0000000..ea35e54 --- /dev/null +++ b/ProjectEuler/Problem6.m @@ -0,0 +1,20 @@ +%ProjectEuler/Problem4.m +%This is a script to answer Problem 4 for Project Euler +%Find the difference between the sum of the squares of the first one hundred natural numbers and the square of the sum. + +%Setup your variables +nums = [1:100]; +squares = nums.^2; +sumOfSquares = sum(squares); +squareOfSums = sum(nums)^2; +value = squareOfSums - sumOfSquares; + +%Print the value +value + +%Cleanup your variables +clear nums; +clear squares; +clear sumOfSquares; +clear squareOfSums; +clear value; \ No newline at end of file