Skip to content

Commit

Permalink
s/divisors/factors/
Browse files Browse the repository at this point in the history
  • Loading branch information
fahadsadah committed Jan 26, 2010
1 parent 3551ef1 commit e79b00e
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions 12.rb
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
#!/usr/bin/ruby
n = 1
divisors = 0
while divisors < 500 do
factors = 0
while factors < 500 do
n = n + 1
triangle = (n*(n+1))/2
divisors = 0
factors = 0
if Math.sqrt(triangle) % 2 == 0 then
to = Math.sqrt(triangle)
else
to = Math.sqrt(triangle).round
end
(1..to).each { |x| divisors = divisors + 1 if triangle % x == 0 }
divisors = divisors * 2
print "#{triangle} has #{divisors} divisors\n"
(1..to).each { |x| factors = factors + 1 if triangle % x == 0 }
factors = factors * 2
print "#{triangle} has #{factors} factors\n"
end
print "divisors is #{divisors}\n"
print "factors is #{factors}\n"

0 comments on commit e79b00e

Please sign in to comment.