012 Highly divisible triangular number.sf 315 B

123456789101112131415161718192021
  1. #!/usr/bin/ruby
  2. # Daniel "Trizen" Șuteu
  3. # https://github.com/trizen
  4. # What is the value of the first triangle number to have over five hundred divisors?
  5. # https://projecteuler.net/problem=12
  6. # Runtime: 0.263s
  7. var n = 0
  8. Inf.times { |k|
  9. n += k
  10. if (n.sigma0 > 500) {
  11. say n
  12. break
  13. }
  14. }