hello there im sorry i can not help you with your problem and like i said i am very sorry i am looking for some help myself first i do not know how to post a question on here second i need help with a program it is in pascal and i need it to decifer from prime or not prime between the numbers 1 and 1000 so plz ne who reads this help i know pascal but im in college so its their thing ne one plz help me thanx again.

4
Contributors
4
Replies
5
Views
11 Years
Discussion Span
Last Post by wylddev
``````procedure TForm1.Button1Click(Sender: TObject);
Function is_prime(r:integer):boolean;
var j:integer;
begin
if (r=1) or (r=2) then begin result:=true;  exit; end;
for j := 2 to r-1 do begin
if (r mod j=0) then begin
result:=false;//not prime
exit;
end;
end;
result := true;//prime
end;

var j,r,k,a,b,c:integer;
red:boolean;

begin
listbox1.Clear ;
listbox2.Clear ;
listbox3.Clear ;
{start value}      i:=strtoint(combobox1.Text );
{end value}  j:= strtoint(combobox2.Text);
for i:=i to j do
begin
if (i mod 2=0) then
else
end;
end;
``````

Edited by Reverend Jim: Fixed formatting

``````procedure TForm1.Button1Click(Sender: TObject);
Function is_prime(r:integer):boolean;
var j:integer;
begin
if (r=1) or (r=2) then begin result:=true;  exit; end;
for j := 2 to r-1 do begin
if (r mod j=0) then begin
result:=false;//not prime
exit;
end;
end;
result := true;//prime
end;

var j,r,k,a,b,c:integer;
red:boolean;

begin
listbox1.Clear ;
listbox2.Clear ;
listbox3.Clear ;
{start value}      i:=strtoint(combobox1.Text );
{end value}  j:= strtoint(combobox2.Text);
for i:=i to j do
begin
if (i mod 2=0) then
else
end;
end;
``````

Edited by Reverend Jim: Fixed formatting

try this function below and see if it works..

function IsPrime(const n: int64): boolean;
var
i: cardinal;
en: extended;
begin
if n <> 2 then begin
en := n;
for i := 2 to round(sqrt(en)) do
if n mod i = 0 then begin
result := false;
exit;
end;
end;
result := n > 0; // or > 1
end;

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.