function IsPrime(Number: Cardinal): Boolean; var cDivisor, cMax : Cardinal; begin Result := False; if Number and 1 = 0 then Exit; cMax := Trunc(Sqrt(Number)) + 1; cDivisor := 3; while cMax > cDivisor do begin if Number mod cDivisor = 0 then Exit; Inc(cDivisor, 2); if Number mod cDivisor = 0 then Exit; Inc(cDivisor, 4); end; Result := True; end;