{
Welcome to GDB Online.
GDB online is an online compiler and debugger tool for C, C++, Python, Java, PHP, Ruby, Perl,
C#, VB, Swift, Pascal, Fortran, Haskell, Objective-C, Assembly, HTML, CSS, JS, SQLite, Prolog.
Code, Compile, Run and Debug online from anywhere in world.
}
program Hello;
type
PUInt16 = ^UInt16;
function fletcher32(data: PUInt16; len: UInt32): UInt32;
var
c0, c1: UInt32;
i: UInt32;
begin
c0 := 0;
c1 := 0;
while len >= 360 do
begin
for i := 1 to 360 do
begin
c0 := c0 + data^;
c1 := c1 + c0;
Inc(data);
end;
c0 := c0 mod 65535;
c1 := c1 mod 65535;
len := len - 360;
end;
for i := 1 to len do
begin
c0 := c0 + data^;
c1 := c1 + c0;
Inc(data);
end;
c0 := c0 mod 65535;
c1 := c1 mod 65535;
{Result}fletcher32 := (c1 shl 16) or c0;
end;
function fletcher32(data: AnsiString): UInt32;
var
len: UInt32;
begin
len := 3; // TODO: сделать верный алгоритм вычисления len через длину переданной строки
{Result}fletcher32 := fletcher32(PUInt16(PAnsiChar(data)), len)
end;
begin
writeln (fletcher32('abcde'));
end.