Commit | Line | Data |
---|---|---|
1662094b BJ |
1 | Berkeley Pascal PI -- Version 1.1 (January 4, 1979) |
2 | ||
3 | Sat Mar 31 11:50 1979 primes.p | |
4 | ||
5 | \0\0\0\0\01\0\0program primes(output); | |
6 | \0\0\0\0\02\0\0const n = 50; n1 = 7; (*n1 = sqrt(n)*) | |
7 | \0\0\0\0\03\0\0var i,k,x,inc,lim,square,l: integer; | |
8 | \0\0\0\0\04\0\0\0\0\0\0prim: boolean; | |
9 | \0\0\0\0\05\0\0\0\0\0\0p,v: array[1..n1] of integer; | |
10 | \0\0\0\0\06\0\0begin | |
11 | \0\0\0\0\07\0\0\0\0\0write(2:6, 3:6); l := 2; | |
12 | \0\0\0\0\08\0\0\0\0\0x := 1; inc := 4; lim := 1; square := 9; | |
13 | \0\0\0\0\09\0\0\0\0\0for i := 3 to n do | |
14 | \0\0\0\010\0\0\0\0\0begin (*find next prime*) | |
15 | \0\0\0\011\0\0\0\0\0\0\0\0repeat x := x + inc; inc := 6-inc; | |
16 | \0\0\0\012\0\0\0\0\0\0\0\0\0\0\0if square <= x then | |
17 | \0\0\0\013\0\0\0\0\0\0\0\0\0\0\0\0\0\0begin lim := lim+1; | |
18 | \0\0\0\014\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0v[lim] := square; square := sqr(p[lim+1]) | |
19 | \0\0\0\015\0\0\0\0\0\0\0\0\0\0\0\0\0\0end ; | |
20 | \0\0\0\016\0\0\0\0\0\0\0\0\0\0\0k := 2; prim := true; | |
21 | \0\0\0\017\0\0\0\0\0\0\0\0\0\0\0while prim and (k<lim) do | |
22 | \0\0\0\018\0\0\0\0\0\0\0\0\0\0\0begin k := k+1; | |
23 | \0\0\0\019\0\0\0\0\0\0\0\0\0\0\0\0\0\0if v[k] < x then v[k] := v[k] + 2*p[k]; | |
24 | \0\0\0\020\0\0\0\0\0\0\0\0\0\0\0\0\0\0prim := x <> v[k] | |
25 | \0\0\0\021\0\0\0\0\0\0\0\0\0\0\0end | |
26 | \0\0\0\022\0\0\0\0\0\0\0\0until prim; | |
27 | \0\0\0\023\0\0\0\0\0\0\0\0if i <= n1 then p[i] := x; | |
28 | \0\0\0\024\0\0\0\0\0\0\0\0write(x:6); l := l+1; | |
29 | \0\0\0\025\0\0\0\0\0\0\0\0if l = 10 then | |
30 | \0\0\0\026\0\0\0\0\0\0\0\0\0\0\0begin writeln; l := 0 | |
31 | \0\0\0\027\0\0\0\0\0\0\0\0\0\0\0end | |
32 | \0\0\0\028\0\0\0\0\0end ; | |
33 | \0\0\0\029\0\0\0\0\0writeln; | |
34 | \0\0\0\030\0\0end . | |
35 | Execution begins... | |
36 | \0\0\0\0\02\0\0\0\0\03\0\0\0\0\05\0\0\0\0\07\0\0\0\011\0\0\0\013\0\0\0\017\0\0\0\019\0\0\0\023\0\0\0\029 | |
37 | \0\0\0\031\0\0\0\037\0\0\0\041\0\0\0\043\0\0\0\047\0\0\0\053\0\0\0\059\0\0\0\061\0\0\0\067\0\0\0\071 | |
38 | \0\0\0\073\0\0\0\079\0\0\0\083\0\0\0\089\0\0\0\097\0\0\0101\0\0\0103\0\0\0107\0\0\0109\0\0\0113 | |
39 | \0\0\0127\0\0\0131\0\0\0137\0\0\0139\0\0\0149\0\0\0151\0\0\0157\0\0\0163\0\0\0167\0\0\0173 | |
40 | \0\0\0179\0\0\0181\0\0\0191\0\0\0193\0\0\0197\0\0\0199\0\0\0211\0\0\0223\0\0\0227\0\0\0229 | |
41 | ||
42 | Execution terminated | |
43 | 1404\0statements executed in 0.16 seconds cpu time |