Skip to content

Instantly share code, notes, and snippets.

@pjc
Created July 1, 2012 22:43
Show Gist options
  • Save pjc/3029913 to your computer and use it in GitHub Desktop.
Save pjc/3029913 to your computer and use it in GitHub Desktop.
Euler Project in Ruby - Problem 6
def sum_of_squares upto
a = 0
(1..upto).each { |x| a += x**2 }
a
end
def square_of_sum upto
a = 0
(1..upto).each { |x| a += x }
a**2
end
puts square_of_sum(100) - sum_of_squares(100)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment