Skip to content

Instantly share code, notes, and snippets.

@wazery
Created March 7, 2014 03:43
Show Gist options
  • Save wazery/9404896 to your computer and use it in GitHub Desktop.
Save wazery/9404896 to your computer and use it in GitHub Desktop.
#! /usr/bin/ruby
def euler_1(n)
numbers = []
sum = 0
(0..n).each do
n -= 1
numbers << n if n % 3 == 0 or n % 5 == 0
end
numbers.each {|num| sum += num}
puts "The sum is #{sum}"
end
n = ARGV[0].to_i
euler_1 n
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment