Project Euler Problem 6


/ Published in: MatLab
Save to your folder(s)



Copy this code and paste it in your HTML
  1. % Alexander DeTrano
  2. % Project Euler - Problem 6
  3. % Find the difference between % the sum of the squares of the first one
  4. % hundred natural numbers and the square of the sum.
  5.  
  6. first100 = [1:100]; %Generate first 100 numbers
  7. sum_squares = sum(first100.^2); %square each element and sum
  8. squares_sum = sum(first100)^2; %sum each element and square
  9. diff = squares_sum-sum_squares

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.