> 英语 >
输入一整数A,判断它是否质数.(提示:若从2到A的平方根的范围内,没有一个数能整除A,则A是质数.)
人气:246 ℃ 时间:2019-09-09 17:46:33
解答
var a,i:longint;t:boolean;
begin
t:=true;
readln(a);
if a=1 then writeln('NO');
if a1 then begin
for i:=2 to trunc(sqrt(a)) do
if a mod i=0 then t:=false;
if t then writeln('YES')else writeln('NO');
end;
end.
推荐
猜你喜欢
© 2024 79432.Com All Rights Reserved.
电脑版|手机版