Annotation of 43BSDTahoe/ucb/pascal/tstpx/src/primes.p, revision 1.1

1.1     ! root        1: program primes(output);
        !             2: const n = 1000; n1 = 33;   (*n1 = sqrt(n)*)
        !             3: var i,k,x,inc,lim,square,l: integer;
        !             4:     prim: boolean;
        !             5:     p,v: array[1..n1] of integer;
        !             6: begin writeln(wallclock);
        !             7:    write(2:6, 3:6); l := 2;
        !             8:    x := 1; inc := 4; lim := 1; square := 9;
        !             9:    for i := 3 to n do
        !            10:    begin (*find next prime*)
        !            11:       repeat x := x + inc; inc := 6-inc;
        !            12:          if square <= x then
        !            13:             begin lim := lim+1;
        !            14:                v[lim] := square; square := sqr(p[lim+1])
        !            15:             end ;
        !            16:          k := 2; prim := true;
        !            17:          while prim and (k<lim) do
        !            18:          begin k := k+1;
        !            19:             if v[k] < x then v[k] := v[k] + 2*p[k];
        !            20:             prim := x <> v[k]
        !            21:          end
        !            22:       until prim;
        !            23:       if i <= n1 then p[i] := x;
        !            24:       write(x:6); l := l+1;
        !            25:       if l = 10 then
        !            26:          begin writeln; l := 0
        !            27:          end
        !            28:    end ;
        !            29:    writeln; writeln(wallclock)
        !            30: end .

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.