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

Version Path
trackler-2.2.1.107 tracks/delphi/exercises/perfect-numbers/uPerfectNumbersExample.pas
trackler-2.2.1.106 tracks/delphi/exercises/perfect-numbers/uPerfectNumbersExample.pas
trackler-2.2.1.105 tracks/delphi/exercises/perfect-numbers/uPerfectNumbersExample.pas
trackler-2.2.1.104 tracks/delphi/exercises/perfect-numbers/uPerfectNumbersExample.pas
trackler-2.2.1.103 tracks/delphi/exercises/perfect-numbers/uPerfectNumbersExample.pas
trackler-2.2.1.102 tracks/delphi/exercises/perfect-numbers/uPerfectNumbersExample.pas
trackler-2.2.1.101 tracks/delphi/exercises/perfect-numbers/uPerfectNumbersExample.pas
trackler-2.2.1.100 tracks/delphi/exercises/perfect-numbers/uPerfectNumbersExample.pas
trackler-2.2.1.99 tracks/delphi/exercises/perfect-numbers/uPerfectNumbersExample.pas
trackler-2.2.1.98 tracks/delphi/exercises/perfect-numbers/uPerfectNumbersExample.pas
trackler-2.2.1.97 tracks/delphi/exercises/perfect-numbers/uPerfectNumbersExample.pas
trackler-2.2.1.96 tracks/delphi/exercises/perfect-numbers/uPerfectNumbersExample.pas
trackler-2.2.1.95 tracks/delphi/exercises/perfect-numbers/uPerfectNumbersExample.pas
trackler-2.2.1.94 tracks/delphi/exercises/perfect-numbers/uPerfectNumbersExample.pas
trackler-2.2.1.93 tracks/delphi/exercises/perfect-numbers/uPerfectNumbersExample.pas
trackler-2.2.1.92 tracks/delphi/exercises/perfect-numbers/uPerfectNumbersExample.pas
trackler-2.2.1.91 tracks/delphi/exercises/perfect-numbers/uPerfectNumbersExample.pas
trackler-2.2.1.90 tracks/delphi/exercises/perfect-numbers/uPerfectNumbersExample.pas
trackler-2.2.1.89 tracks/delphi/exercises/perfect-numbers/uPerfectNumbersExample.pas
trackler-2.2.1.88 tracks/delphi/exercises/perfect-numbers/uPerfectNumbersExample.pas