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.180 tracks/delphi/exercises/armstrong-numbers/uArmstrongNumbersExample.pas
trackler-2.2.1.179 tracks/delphi/exercises/armstrong-numbers/uArmstrongNumbersExample.pas
trackler-2.2.1.178 tracks/delphi/exercises/armstrong-numbers/uArmstrongNumbersExample.pas
trackler-2.2.1.177 tracks/delphi/exercises/armstrong-numbers/uArmstrongNumbersExample.pas
trackler-2.2.1.176 tracks/delphi/exercises/armstrong-numbers/uArmstrongNumbersExample.pas
trackler-2.2.1.175 tracks/delphi/exercises/armstrong-numbers/uArmstrongNumbersExample.pas
trackler-2.2.1.174 tracks/delphi/exercises/armstrong-numbers/uArmstrongNumbersExample.pas
trackler-2.2.1.173 tracks/delphi/exercises/armstrong-numbers/uArmstrongNumbersExample.pas
trackler-2.2.1.172 tracks/delphi/exercises/armstrong-numbers/uArmstrongNumbersExample.pas
trackler-2.2.1.171 tracks/delphi/exercises/armstrong-numbers/uArmstrongNumbersExample.pas
trackler-2.2.1.170 tracks/delphi/exercises/armstrong-numbers/uArmstrongNumbersExample.pas
trackler-2.2.1.169 tracks/delphi/exercises/armstrong-numbers/uArmstrongNumbersExample.pas
trackler-2.2.1.167 tracks/delphi/exercises/armstrong-numbers/uArmstrongNumbersExample.pas
trackler-2.2.1.166 tracks/delphi/exercises/armstrong-numbers/uArmstrongNumbersExample.pas
trackler-2.2.1.165 tracks/delphi/exercises/armstrong-numbers/uArmstrongNumbersExample.pas
trackler-2.2.1.164 tracks/delphi/exercises/armstrong-numbers/uArmstrongNumbersExample.pas
trackler-2.2.1.163 tracks/delphi/exercises/armstrong-numbers/uArmstrongNumbersExample.pas
trackler-2.2.1.162 tracks/delphi/exercises/armstrong-numbers/uArmstrongNumbersExample.pas
trackler-2.2.1.161 tracks/delphi/exercises/armstrong-numbers/uArmstrongNumbersExample.pas
trackler-2.2.1.160 tracks/delphi/exercises/armstrong-numbers/uArmstrongNumbersExample.pas