Created
March 7, 2014 03:43
-
-
Save wazery/9404896 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /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