1
0
mirror of https://bitbucket.org/Dennis07/lina-components.git synced 2025-08-24 21:49:04 +02:00

Version 1.0 DEV 1.16a

Signed-off-by: Dennis07 <den.goehlert@t-online.de>
This commit is contained in:
Dennis07
2017-05-21 15:21:08 +02:00
parent a9c7d580e5
commit b0dd4aab81

View File

@@ -459,6 +459,10 @@ type
function ArrayToSet(Elements: array of Byte): TByteSet; overload;
function ArrayToSet(Elements: array of Char): TCharSet; overload;
{ Sonstige }
function Prime(X: ShortInt): Boolean; overload;
function Prime(X: Byte): Boolean; overload;
function Prime(X: Integer): Boolean; overload;
function Prime(X: Cardinal): Boolean; overload;
function StringToRange(const S: String; var Range: TRange): Boolean;
function ExprInStr(const S: String; Position: Integer): String;
function Factional(X: Byte): Cardinal;
@@ -1868,6 +1872,46 @@ begin
end;
end;
function Prime(X: ShortInt): Boolean;
begin
Result := Prime(Byte(Abs(X)));
end;
function Prime(X: Byte): Boolean;
const
PrimeNumbers = [ 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47,
53, 59, 61, 67, 71, 73, 79, 83, 89, 97,101,103,107,109,113,
127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,
199,211,223,227,229,233,239,241,251 ];
begin
Result := X in PrimeNumbers;
end;
function Prime(X: Integer): Boolean;
begin
Result := Prime(Cardinal(Abs(X)));
end;
function Prime(X: Cardinal): Boolean;
var
Index: Integer;
begin
Result := Prime(Byte(X));
if (not Result) and (X > MAXBYTE) then
begin
Index := 2;
while Index <= X div Index do
begin
if X mod Index = 0 then
begin
Exit;
end;
Inc(Index);
end;
Result := True;
end;
end;
function StringToRange(const S: String; var Range: TRange): Boolean;
var
Current: PChar;