Skip to content

Instantly share code, notes, and snippets.

@pjc
Created July 1, 2012 22:26
Show Gist options
  • Save pjc/3029856 to your computer and use it in GitHub Desktop.
Save pjc/3029856 to your computer and use it in GitHub Desktop.
Euler Project in Ruby - Problem 1
y = 0
(1..999).each { |x| y = y + x if (x % 3 == 0) || (x % 5 == 0) }
puts y
@suyesh
Copy link

suyesh commented Aug 5, 2015

Here is my code sum = (1...1000).select {|x| x if x % 3 == 0 || x % 5 == 0}.reduce(:+)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment