Sha256: 17330369b8adc05ed22dc117657c0816454e0106d82ea9809b164f2a480150e3
Contents?: true
Size: 622 Bytes
Versions: 275
Compression:
Stored size: 622 Bytes
Contents
unit uPerfectNumbers; interface type NumberType = (Perfect, Abundant, Deficient); PerfectNumber = class public class function Classify(aNumber: integer): Numbertype; static; end; implementation class function PerfectNumber.Classify(aNumber: Integer): NumberType; var sumOfFactors: integer; i: integer; begin sumOfFactors := 0; for i := 1 to aNumber - 1 do if aNumber mod i = 0 then sumOfFactors := sumOfFactors + i; if sumOfFactors < aNumber then result := Deficient else if sumOfFactors = aNumber then result := Perfect else result := Abundant; end; end.
Version data entries
275 entries across 275 versions & 1 rubygems