2009-02-09 ProjectEuler 1 Ruby Programming ProjectEuler Ruby #!/usr/bin/ruby #ans 1 p (0...1000).select {|i|i%3==0||i%5==0}.inject(0) {|a,b|a+b} #ans 2 require "enumerator" p ((0...1000).to_enum(:step,3).to_a+(0...1000).to_enum(:step,5).to_a).uniq.inject(0) {|a,b|a+b}