Sha256: d2b0859d940da6c91cffe666195876472419e1c9efae204b040e8652edc89d61

Contents?: true

Size: 562 Bytes

Versions: 105

Compression:

Stored size: 562 Bytes

Contents

unit uArmstrongNumbers;

interface
uses System.SysUtils, System.Math;

function isArmstrongNumber(aNumber: integer): Boolean;

implementation

function isArmstrongNumber(aNumber: integer): Boolean;
var
  wrkNumber: integer;
  Calculation: integer;
  valLength: integer;
begin
  wrkNumber := aNumber;
  Calculation := 0;
  valLength := aNumber.ToString.Length;
  while wrkNumber > 0 do
  begin
    Calculation := Calculation + trunc(IntPower((wrkNumber mod 10), valLength));
    wrkNumber := wrkNumber div 10;
  end;
  result := aNumber = Calculation;
end;

end.

Version data entries

105 entries across 105 versions & 1 rubygems

Version Path
trackler-2.2.1.98 tracks/delphi/exercises/armstrong-numbers/uArmstrongNumbersExample.pas
trackler-2.2.1.97 tracks/delphi/exercises/armstrong-numbers/uArmstrongNumbersExample.pas
trackler-2.2.1.96 tracks/delphi/exercises/armstrong-numbers/uArmstrongNumbersExample.pas
trackler-2.2.1.95 tracks/delphi/exercises/armstrong-numbers/uArmstrongNumbersExample.pas
trackler-2.2.1.94 tracks/delphi/exercises/armstrong-numbers/uArmstrongNumbersExample.pas
trackler-2.2.1.93 tracks/delphi/exercises/armstrong-numbers/uArmstrongNumbersExample.pas
trackler-2.2.1.92 tracks/delphi/exercises/armstrong-numbers/uArmstrongNumbersExample.pas
trackler-2.2.1.91 tracks/delphi/exercises/armstrong-numbers/uArmstrongNumbersExample.pas
trackler-2.2.1.90 tracks/delphi/exercises/armstrong-numbers/uArmstrongNumbersExample.pas
trackler-2.2.1.89 tracks/delphi/exercises/armstrong-numbers/uArmstrongNumbersExample.pas
trackler-2.2.1.88 tracks/delphi/exercises/armstrong-numbers/uArmstrongNumbersExample.pas
trackler-2.2.1.87 tracks/delphi/exercises/armstrong-numbers/uArmstrongNumbersExample.pas
trackler-2.2.1.86 tracks/delphi/exercises/armstrong-numbers/uArmstrongNumbersExample.pas
trackler-2.2.1.85 tracks/delphi/exercises/armstrong-numbers/uArmstrongNumbersExample.pas
trackler-2.2.1.84 tracks/delphi/exercises/armstrong-numbers/uArmstrongNumbersExample.pas
trackler-2.2.1.83 tracks/delphi/exercises/armstrong-numbers/uArmstrongNumbersExample.pas
trackler-2.2.1.82 tracks/delphi/exercises/armstrong-numbers/uArmstrongNumbersExample.pas
trackler-2.2.1.81 tracks/delphi/exercises/armstrong-numbers/uArmstrongNumbersExample.pas
trackler-2.2.1.80 tracks/delphi/exercises/armstrong-numbers/uArmstrongNumbersExample.pas
trackler-2.2.1.79 tracks/delphi/exercises/armstrong-numbers/uArmstrongNumbersExample.pas