Skip to content

Instantly share code, notes, and snippets.

@charlesponti
Last active December 17, 2015 01:18
Show Gist options
  • Save charlesponti/5526882 to your computer and use it in GitHub Desktop.
Save charlesponti/5526882 to your computer and use it in GitHub Desktop.
Project Euler: Problem 6
def sum_sq_diff(max)
sum_sqs = 0
sq_sums = 0
1.upto(max) { |i| sum_sqs += i**2 }
1.upto(max) { |i| sq_sums += i }
p sq_sums**2 - sum_sqs
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment