cwtests/cw03/primes.while
changeset 836 a3418ee8c404
child 852 8706b846a3e0
equal deleted inserted replaced
835:08b157566a73 836:a3418ee8c404
       
     1 // prints out prime numbers from 2 to 100 
       
     2 
       
     3 end := 100;
       
     4 n := 2;
       
     5 while (n < end) do {
       
     6   f := 2;
       
     7   tmp := 0;
       
     8   while ((f < n / 2 + 1) && (tmp == 0)) do {
       
     9     if ((n / f) * f == n) then  { tmp := 1 } else { skip };
       
    10     f := f + 1
       
    11   };
       
    12   if (tmp == 0) then { write(n) } else { skip };
       
    13   n  := n + 1
       
    14 }