\subsubsection{Sieve of Eratosthenes} Perhaps the simplest example is provided by the old algorithm for computing the sequence of primes. Assume that the timed sequence of natural numbers, starting with {\tt 2} is produced on {\tt Val}. The program asserts that each such number {\tt N} is prime by default --- unless there is reason to believe that it is not. If the default is not defeated, an agent {\tt sieve} is set up that declares every subsequent number {\tt X} {\tt not\_prime} if it is a multiple of {\tt N}. \begin{ccprogram} \agent primes(Val, Output):: always\ N\$\(Val:N -> not\_prime ~> [\{Output:N\}, always\ sieve(N, Val)].. \agent sieve(N, Val) :: X\$(Val:X -> X\ mod\ N {={}}:{={}} 0 -> \{not\_prime\}).. \end{ccprogram} The overall program is obtained by coupling with the {\tt counter} from the previous section: \begin{ccprogram} \agent primes(Primes) :: Val^[primes(Val, Primes), counter(2,Val)].. \end{ccprogram} \noindent The program may be run in a harness (using {\tt watching}) in the same way as {\tt fib}.