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