Skip to content

Instantly share code, notes, and snippets.

@rhysd
Created May 12, 2012 19:59
Show Gist options
  • Save rhysd/2668625 to your computer and use it in GitHub Desktop.
Save rhysd/2668625 to your computer and use it in GitHub Desktop.
euler 1
#!/usr/bin/env ruby
# -*- coding: utf-8 -*-
MAX = 1000-1
def f(i)
(1..(MAX/i)).map{|n| n*i }.inject 0,&:+
end
#
# main
#
if __FILE__ == $0 then
puts f(3)+f(5)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment