Posted By

mju4t on 02/03/11


Tagged

project Euler


Versions (?)

Project Euler Problem 6


 / Published in: MatLab
 

  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  

You need to login to post a comment.