1 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3 %% Sieve of eratosthenes to compute primes
4 %% thom fruehwirth 920218-20, 980311
5 %% christian holzbaur 980207 for Sicstus CHR
7 %% ported to hProlog by Tom Schrijvers
9 :- module(primes,[main/0,main/1]).
11 :- constraints candidate/1.
12 :- constraints prime/1.
14 candidate(1) <=> true.
15 candidate(N) <=> primes:prime(N), N1 is N - 1, primes:candidate(N1).
17 absorb @ prime(Y) \ prime(X) <=> 0 =:= X mod Y | true.
27 write(bench(primes ,N,Time,0,hprolog)), write('.'),nl.