Created
August 14, 2015 23:48
-
-
Save joegiralt/32552523a1fc9e10d469 to your computer and use it in GitHub Desktop.
Project Euler 6 sum_square_difference
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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