Skip to content

Instantly share code, notes, and snippets.

@joegiralt
Created August 14, 2015 23:48
Show Gist options
  • Save joegiralt/32552523a1fc9e10d469 to your computer and use it in GitHub Desktop.
Save joegiralt/32552523a1fc9e10d469 to your computer and use it in GitHub Desktop.
Project Euler 6 sum_square_difference
def sum_square_difference(num)
((1..num).map{ |elem| elem ** 2 }.inject(:+) - (1..num).inject(:+) ** 2).abs
end
puts sum_square_difference(100)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment