2 câu trả lời
uses crt;
var n:longint;
function nt(a:longint):boolean;
var i:longint;
begin
i:=2;
while(a>1)and(a mod i<>0)do inc(i);
nt:=i=a;
end;
function snt(a:longint):boolean;
begin
if a>20 then snt:=true else
begin
while (a<>0)and(nt(a)) do
a:=a div 10;
snt:=a=0;
end;
end;
begin
clrscr;
write('Nhap so nguyen n: ');readln(n);
writeln(snt(n));
readln
end.
uses crt;
var n:longint;
function nt(n:longint):boolean;
var i:longint;
begin
if n<2 then exit(false);
for i:=2 to trunc(sqrt(n)) do
if n mod i=0 then exit(false);
exit(true);
end;
function snt(n:longint):boolean;
begin
if n<23 then exit(false) else
begin
while n<>0 do
begin
if nt(n)=false then exit(false);
n:=n div 10;
end;
exit(true);
end;
end;
begin
clrscr;
readln(n);
write(snt(n));
readln;
end.