08-04-2011، 10:36 PM
سورس محاسبه تعداد اعداد اول
کد:
uses wincrt;
var
i,a,n,j,cnt,k : integer;
flag : boolean;
begin
writeln('Enter Number For N');
readln(n);
cnt:=0;
for i:= 1 to n do
begin
if i<=n then
begin
writeln('enter ',i,' number');
readln(a);
if a=1 then
begin
writeln('number 1 is not prime and complete therefore enter an other number');
readln(a);
i:=i+1
end;
flag:=true;
k:=0;
j:=2;
end;
while (j<=a div 2) and (k=0) do
begin
if (a mod j =0) then
k:=1;
j:=j+1;
end;
if (k=0) then
cnt:=cnt+1;
end;
writeln('number of prime number is :',cnt)
end.
گروه دور همی پارسی کدرز
https://t.me/joinchat/GxVRww3ykLynHFsdCvb7eg
https://t.me/joinchat/GxVRww3ykLynHFsdCvb7eg