Skip to content

Instantly share code, notes, and snippets.

@masahixixi
Created November 21, 2012 17:01
Show Gist options
  • Save masahixixi/4126055 to your computer and use it in GitHub Desktop.
Save masahixixi/4126055 to your computer and use it in GitHub Desktop.
ProjectEuler #12
require "prime"
count = 501
tri_num = 0
div = Array.new
num = 0
loop do
num += 1
tri_num += num
div = tri_num.prime_division
div_count = 1
div.each do |i|
div_count = div_count * (i[1]+1)
end
if div_count >= count
p tri_num
break
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment