gitweb on Svarog

projekti pod git sistemom za održavanje verzija -- projects under the git version control system
docs - added MircoJava specification pdfs that were used in this project
[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) {print(chr(13)); print(chr(10)); npp = 0;}
11 print(x, 5);
12 npp++;
13 }
15 void found(int x)
16 int i;
17 {
18 put(x);
19 i = x;
20 while (i <= max) {sieve[i] = 'o'; i = i + x;}
21 }
23 void main()
24 int i;
25 {
26 read(max);
27 npp = 0;
28 sieve = new char[max+1];
29 i = 0;
30 while (i <= max) {sieve[i] = 'x'; i++;}
31 i = 2;
32 while (i <= max) {
33 found(i);
34 while(i <= max && sieve[i] == 'o') i++;
35 }
36 }
38 }//test
Svarog.pmf.uns.ac.rs/gitweb maintanance Doni Pracner