Skip to content

Commit

Permalink
[Alan] Modify sieve.alan (change size of primes array) (#38)
Browse files Browse the repository at this point in the history
* Change size of primes array to 101 so primes[0] and primes[100] element can be accessed

* [alan] Use strict inequalities in while loops to make them uniform
  • Loading branch information
harrisp28 authored Sep 25, 2024
1 parent de09fb1 commit 94cbf66
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions alan/programs/sieve.alan
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ main(): proc
if (primes[i] == shrink(1)) {
-- Mark all multiples of i as false (not prime)
j = i * i;
while (j <= n) {
while (j < n) {
primes[j] = shrink(0);
j = j + i;
}
Expand All @@ -40,7 +40,7 @@ main(): proc

-- Print all prime numbers
i = 2;
while (i <= n) {
while (i < n) {
if (primes[i] == shrink(1)){
writeInteger(i);
writeChar(' ');
Expand Down

0 comments on commit 94cbf66

Please sign in to comment.