gitweb on Svarog

projekti pod git sistemom za održavanje verzija -- projects under the git version control system
make log times even more specific
[mjc2wsl.git] / samples / eratos.mj
1 program Eratos
3 char[] sieve;
4 int max; // maximum prime to be found
5 int npp; // numbers per page
7 {
8 void put(int x)
9 {
10 if (npp == 10) {
11 print(chr(13));
12 print(chr(10));
13 npp = 0;
14 }
15 print(x, 5);
16 npp++;
17 }
19 void found(int x)
20 int i;
21 {
22 put(x);
23 i = x;
24 while (i <= max) {
25 sieve[i] = 'o'; i = i + x;
26 }
27 }
29 void main()
30 int i;
31 {
32 read(max);
33 npp = 0;
34 sieve = new char[max+1];
35 i = 0;
36 while (i <= max) {
37 sieve[i] = 'x'; i++;
38 }
39 i = 2;
40 while (i <= max) {
41 found(i);
42 while(i <= max && sieve[i] == 'o')
43 i++;
44 }
45 }
47 }//test
Svarog.pmf.uns.ac.rs/gitweb maintanance Doni Pracner