Sha256: d6aed01eeb6159d7bed981220b9d109987fec20cf48c21ab4277ce57be612979
Contents?: true
Size: 204 Bytes
Versions: 41
Compression:
Stored size: 204 Bytes
Contents
#!/usr/bin/env ruby # Compute the n'th triangle number - the hard way # triangle(n) == (n * (n+1)) / 2 def triangle(n) tri = 0 0.upto(n) do |i| tri += i end return tri end puts triangle(3)
Version data entries
41 entries across 41 versions & 6 rubygems