Delphi - Prime Numbers : <p>A prime number (or a prime) is a natural number greater than 1 that has no positive divisors other than 1 and itself.
What I'm doing is this to check if the number is prime or not :</p>

<pre><code>begin
writeln('give a number ');
readln(N);  S := 0;
for I := 1 to N do
if N mod I = 0 then
 S := S + 1 ;

 if S = 2 then
 writeln('Prime')
 else
 writeln('not prime');
 sleep(50000);

end.
</code></pre>

<p>I'm now trying to get all the prime numbers between 1 and 100 (or any other number) using this :</p>

<pre><code>begin
writeln('give a number ');
readln(N);

for I := 1 to N do  begin
        S := 0;
 for J := 1 to I do
  begin
 if I mod J = 0 then
 S := S +1 ;  if S = 2 then
       writeln(I);

 end;
   end;
sleep(500000000000);
 end.
</code></pre>

<p>But it's not reallyworking .</p>
