Sha256: dffce44c33fcd24ebda01af34ee2d7ca2dc1f76b25879a0bd056fb7dbfdc8344

Contents?: true

Size: 641 Bytes

Versions: 318

Compression:

Stored size: 641 Bytes

Contents

unit uGrains;

interface

type
  Grains = class
    class function Square(aInteger: integer): UInt64; static;
    class function Total: UInt64; static;
  end;

implementation
uses System.SysUtils;

class function Grains.Square(aInteger: integer): UInt64;
begin
  if (aInteger < 1) or (aInteger > 64) then
    raise ERangeError.CreateFmt('Argument of %d is out of bounds.  Must be > 0 and < 65',[aInteger]);

  if aInteger = 1 then
    result := 1
  else
    result := 2 * Square(aInteger - 1);
end;

class function Grains.Total: UInt64;
var i: integer;
begin
  result := 0;
  for i := 1 to 64 do
    result := result + Square(i);
end;

end.

Version data entries

318 entries across 318 versions & 1 rubygems

Version Path
trackler-2.0.6.40 tracks/delphi/exercises/grains/uGrainsExample.pas
trackler-2.0.6.39 tracks/delphi/exercises/grains/uGrainsExample.pas
trackler-2.0.6.38 tracks/delphi/exercises/grains/uGrainsExample.pas
trackler-2.0.6.37 tracks/delphi/exercises/grains/uGrainsExample.pas
trackler-2.0.6.36 tracks/delphi/exercises/grains/uGrainsExample.pas
trackler-2.0.6.35 tracks/delphi/exercises/grains/uGrainsExample.pas
trackler-2.0.6.34 tracks/delphi/exercises/grains/uGrainsExample.pas
trackler-2.0.6.33 tracks/delphi/exercises/grains/uGrainsExample.pas
trackler-2.0.6.32 tracks/delphi/exercises/grains/uGrainsExample.pas
trackler-2.0.6.31 tracks/delphi/exercises/grains/uGrainsExample.pas
trackler-2.0.6.30 tracks/delphi/exercises/grains/uGrainsExample.pas
trackler-2.0.6.29 tracks/delphi/exercises/grains/uGrainsExample.pas
trackler-2.0.6.28 tracks/delphi/exercises/grains/uGrainsExample.pas
trackler-2.0.6.27 tracks/delphi/exercises/grains/uGrainsExample.pas
trackler-2.0.6.26 tracks/delphi/exercises/grains/uGrainsExample.pas
trackler-2.0.6.25 tracks/delphi/exercises/grains/uGrainsExample.pas
trackler-2.0.6.24 tracks/delphi/exercises/grains/uGrainsExample.pas
trackler-2.0.6.23 tracks/pascal/exercises/grains/uGrainsExample.pas