Ask Question

Name:
Title:
Your Question:

Answer Question

Name:
Your Answer:
User Submitted Source Code!


Description:
  p1.pas
Language: PASCAL
Code:
program p1;
var ctr, a, b, c, d, e, n, prime: integer;
 
begin
    write  ('Find nth prime: ');
    readln (n);
    a:=2;
    ctr:=0;
    while ctr<n do
    begin
        b := 2;
        prime := 1;
        d:= b*b;
        while d<= a do
        begin
            c:= a MOD b;
              if c=0 then
            begin
                    prime:=0;
                    break;
            end
            else
               begin
                b:= b+1;
               end
          end;                
        if prime=1 then
          begin
            ctr:= ctr+1;
          end
        else
        begin
            a:= a+1;
        end
     end
    {write('nth prime is: ');}
    readln;
end.


          
          
Comments: