mirror of
https://bitbucket.org/Mattrixwv/octavefunctions.git
synced 2025-12-06 18:53:57 -05:00
Added the 6th problem
This commit is contained in:
20
ProjectEuler/Problem6.m
Normal file
20
ProjectEuler/Problem6.m
Normal file
@@ -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;
|
||||
Reference in New Issue
Block a user