Sha256: 1ad62a96141b950abdcdc23f44f337b2b55b0c0ea29d0dab53c6ded9cbf32bdf
Contents?: true
Size: 738 Bytes
Versions: 130
Compression:
Stored size: 738 Bytes
Contents
enum NumberClassification { case perfect case abundant case deficient } struct NumberClassifier { let number: Int var sum: Int { return aliquotSum(number) } var classification: NumberClassification { switch sum { case let sum where sum == number : return NumberClassification.perfect case let sum where sum < number : return NumberClassification.deficient default: return NumberClassification.abundant } } func aliquotSum (_ input: Int) -> Int { let array = Array(1..<(input-1)) return array.filter({input % $0 == 0}).reduce(0, +) } init(number: Int) { self.number = number } }
Version data entries
130 entries across 130 versions & 1 rubygems