Sha256: 05308c01130b4f9b867d52e5cb7183232f95d2e769fa0dabc0f740d3485da34c
Contents?: true
Size: 201 Bytes
Versions: 15
Compression:
Stored size: 201 Bytes
Contents
class Integer def n_gonal?(n) raise ArgumentError unless n.is_a?(Integer) and n >= 3 return true if zero? ((Math.sqrt((8*n - 16)*self + (n-4)**2) + n - 4) / (2*n - 4)).integer? end end
Version data entries
15 entries across 15 versions & 1 rubygems