1000到2000内第一百个素数是多少 从从小到大 急

···急··谢谢
2025-04-24 01:13:01
推荐回答(2个)
回答1:

先给你说一个 判断素数的函数:
=============================================================
function judge(num:longint):boolean;
var
i:longint;
begin
for i:=2 to trunc(sqrt(num)) do//从2到所判断数的算术跟
begin
if num mod i=0
then exit(false);//不是素数
end;
exit(true);//是素数
end;
=============================================================
求第一百个素数的代码如下:
=============================================================
program t;
const
maxn=10000000;
var
i,j,k,total:longint;
a:array[1..maxn]of longint;

function judge(num:longint):boolean;
var
i:longint;
begin
for i:=2 to trunc(sqrt(num)) do//从2到所判断数的算术跟
begin
if num mod i=0
then exit(false);//不是素数
end;
exit(true);//是素数
end;

begin
for i:=1000 to 2000 do
begin
if judge(i)
then begin
inc(total);
a[total]:=i;
end;
end;
writeln(a[100]);
end.
=============================================================
答案是1721
希望对你有所帮助

回答2:

素数