-
Notifications
You must be signed in to change notification settings - Fork 3
/
sieve.a60
30 lines (28 loc) · 1.06 KB
/
sieve.a60
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
b̲e̲g̲i̲n̲
c̲o̲m̲m̲e̲n̲t̲ zeef van Erathostenes;
i̲n̲t̲e̲g̲e̲r̲ p, m;
b̲e̲g̲i̲n̲
B̲o̲o̲l̲e̲a̲n̲ a̲r̲r̲a̲y̲ prime [2 : 1000000];
PRINTTEXT(`Computing primes...');
f̲o̲r̲ p := 2, 3 s̲t̲e̲p̲ 2 u̲n̲t̲i̲l̲ 1000000 d̲o̲
prime[p] := t̲r̲u̲e̲;
PRINTTEXT(`.');
f̲o̲r̲ p := 2, 3 s̲t̲e̲p̲ 2 u̲n̲t̲i̲l̲ 1000 d̲o̲ b̲e̲g̲i̲n̲
i̲f̲ prime[p] t̲h̲e̲n̲
f̲o̲r̲ m := p * p s̲t̲e̲p̲ p u̲n̲t̲i̲l̲ 1000000 d̲o̲
prime[m] := f̲a̲l̲s̲e̲;
i̲f̲ p ÷ 100 * 100 + 1 = p t̲h̲e̲n̲
PRINTTEXT(`.');
e̲n̲d̲;
NLCR;
m := 0;
f̲o̲r̲ p := 2, 3 s̲t̲e̲p̲ 2 u̲n̲t̲i̲l̲ 1000000 d̲o̲ b̲e̲g̲i̲n̲
i̲f̲ prime[p] t̲h̲e̲n̲ b̲e̲g̲i̲n̲
m := m + 1
e̲n̲d̲
e̲n̲d̲;
PRINTTEXT(`Number of primes below 1000 000: ');
print(m);
NLCR
e̲n̲d̲
e̲n̲d̲