Sha256: 64e17d044b68394ab2618552b16bb7e1be1e565ff122425eb30f6b8bab8b8d07
Contents?: true
Size: 382 Bytes
Versions: 4
Compression:
Stored size: 382 Bytes
Contents
class Fixnum # Factorial of number # 5.factorial == 5 x 4 x 3 x 2 x 1 == 120 #------------------------------------------------------------------------------ def factorial return 1 if self.zero? (1..self).inject(:*) end #------------------------------------------------------------------------------ def as_boolean (self > 0) ? true : false end end
Version data entries
4 entries across 4 versions & 1 rubygems