initial commit
This commit is contained in:
27
MicroJava Compiler/Prims.mj
Normal file
27
MicroJava Compiler/Prims.mj
Normal file
@@ -0,0 +1,27 @@
|
||||
program Prims
|
||||
{
|
||||
|
||||
void print_prims (int n)
|
||||
int[] numbers;
|
||||
int i, j;
|
||||
{
|
||||
numbers = new int[n];
|
||||
i = 0;
|
||||
while(i < n) {
|
||||
if(1 < i && numbers[i] == 0) {
|
||||
print(i);
|
||||
print('\n');
|
||||
j = i;
|
||||
while(j < n) {
|
||||
numbers[j]++;
|
||||
j += i;
|
||||
}
|
||||
}
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
void main () {
|
||||
print_prims(1000);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user