(04-05-2020, 11:41 AM)Agmcz كتب : السلام عليكميمكن الاستغناء عن متغير I
بداية الحساب من الأخير و الضرب في 4 تصاعديا دون مراعات طول المفتاح
PHP كود :function CleCCP(const CCP: string): Integer;
var
L,I: Integer;
begin
Result := 0;
I := 4;
for L := Length(CCP) downto 1 do
begin
Result := Result + StrToInt(CCP[L]) * I;
Inc(I)
end;
Result := Result mod 100;
end;
بهذه الطريقة
PHP كود :
function CleCCP(const CCP: string): Integer;
var
I: Byte;
begin
Result := 0;
for I := Length(CCP) downto 1 do
Result := Result + StrToInt(CCP[I]) * (Length(CCP) - I + 4);
Result := Result mod 100;
end;

