program RemoveDigitPrime;
uses
SysUtils;
function RemoveTheNDigit(num: LongInt; N: Integer): LongInt;
var
s: string;
begin
s := IntToStr(num);
Delete(s, N + 1, 1); { Pascal strings are 1‑based }
RemoveTheNDigit := StrToInt(s);
end;
function IsPrime(n: LongInt): Boolean;
var
i, limit: LongInt;
begin
if (n < 2) or ((n mod 2 = 0) and (n <> 2)) then
begin
IsPrime := False;
Exit;
end;
limit := Trunc(Sqrt(n));
i := 3;
while i <= limit do
begin
if n mod i = 0 then
begin
IsPrime := False;
Exit;
end;
i := i + 2;
end;
IsPrime := True;
end;
var
n, totalDigits, i, tmp: LongInt;
s: string;
begin
n := 78919;
s := IntToStr(n);
totalDigits := Length(s);
for i := 0 to totalDigits - 1 do
begin
tmp := RemoveTheNDigit(n, i);
if IsPrime(tmp) then
begin
WriteLn('yes number = ', tmp);
Break;
end;
end;
end.
(*
run:
yes number = 7919
*)